From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 1B6DD3858D28 for ; Tue, 5 Dec 2023 07:30:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B6DD3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1B6DD3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701761410; cv=none; b=VXbuAluKw0D6GAENxz0bql8V8npIbe+QaNaKbymezHvPyakrbH//PW91bfCzFJ0JqacM/JKaVmS3WYOA+k83K/4p7relZilOoYi11n3ml+r1Fmo29qIoPeA/Hoeurr1OJj7JryfjUrLCcyhBYduzi+r0U9kK57lmYSR8tnyYvoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701761410; c=relaxed/simple; bh=Fdl+Zx+tVRVEXOwjhZTajXDbzYR+xu/Fi+fuzeDtQpw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=hGxoQRQX1I8/+zkr/cxHb0QEogk+AJu8mLoka/WeG8S0n8uvgekfVFbnMEjnpOal9JB/6Vxg92k8L33s/Sh7GFmcRf0f1aK17wjOdKapjynzbfHtV8QDtmY3zc77wnR693c/0f68AE+XeUdrF3TJXU6QTHNtXPJIQi+AKYHNh3Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-54cde11d0f4so2028525a12.2 for ; Mon, 04 Dec 2023 23:30:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1701761407; x=1702366207; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=opKRF+juqg8HjgT6+G26jB3AWooSJ0ZMmu622swEy7Y=; b=VU8BCLIbsSYIhLLujCL/z6DXXI978NO17NS8VuE0SK/crsJ0mQWBptNYtr3rbZgbcH eRuTu7zYVgm3mYQjHDmCGvm5tycnX6ZCjaLUCMsZkBDag46Xb6UUAAKgdysmAPyOXnkc UnWoPklMiVNgCaBeWaB+4Bo7YDUjhj7Tn7/csNXpaJ+ZUmQ27R74wHV1QiT0+aQMLz/F HaeqAYE6M4p1AywugMP7hg9XfHPrZri6cfQz3IcWKysnR7j3ZWAorSL4pwco6LGm7O5c UZnDz1xln0I954pw+YULvMmGlfmoekwKwFd0IOdqZ3kdV38uI8SyprCWao7KbnERwJPn ModA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701761407; x=1702366207; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=opKRF+juqg8HjgT6+G26jB3AWooSJ0ZMmu622swEy7Y=; b=b8W3sdPxbxQtyF5NEDgvq1H7AiPDIUZoknm052TcbNRqAqMLCMxUx9oJABWkkBH9A/ be1b+x7srWLlXiGIEexCFeuVBseV2+yyDKFAXIUntmEhGJfxrxQfD7b4M+coht5artzI L45Xbd7fH580WrEmHtHaZppWywunpI6/Dz+ypmilXw/kWatX2UUITgwbazUKdl9rXHU5 hLO6BP7If3lh5DSWj707a68IyVCesfHd0nHvlxhKFkf3/KyLZZySOQAzUy+A2mEj5l28 V+ePx5JOdagC3IPg/vsqIwzxFdA8Qlc2UEBhvKqsKkixZuSPsFbW5W0/hM0z8E/AxkhL uFEw== X-Gm-Message-State: AOJu0Yz7+Ql6lGiOIjTYFXX6MNVV57jSeCbcYGKmxcE4TdAHtTqqX9HP PSllAe2J/Z+C0xsfz6k0O1ifhkQVHr76UCtCgy3ITg== X-Google-Smtp-Source: AGHT+IG3/0JY6R2k5iogGV0VqF9Dd1ay6dCKdfd+bKKcuq3A4a6HYaaF37GtM1DIKFU7UapgkmMBSoIVX21tduHURVk= X-Received: by 2002:a50:f682:0:b0:54d:4b7:6f4f with SMTP id d2-20020a50f682000000b0054d04b76f4fmr575961edn.38.1701761406745; Mon, 04 Dec 2023 23:30:06 -0800 (PST) MIME-Version: 1.0 References: <20231204115340.CA9C813588@imap2.dmz-prg2.suse.org> In-Reply-To: From: "Patrick O'Neill" Date: Mon, 4 Dec 2023 23:29:55 -0800 Message-ID: Subject: Re: [PATCH] tree-optimization/112827 - corrupt SCEV cache during SCCP To: "Li, Pan2" Cc: Richard Biener , "gcc-patches@gcc.gnu.org" , "juzhe.zhong@rivai.ai" Content-Type: multipart/alternative; boundary="000000000000244e2c060bbe3487" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,HTML_MESSAGE,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000244e2c060bbe3487 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Relevant bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112848 Thanks, Patrick On Mon, Dec 4, 2023 at 11:20=E2=80=AFPM Li, Pan2 wrote: > Hi Richard, > > It looks like this patch result in one ICE for RISC-V backend for case > tree-ssa.exp=3Dssa-sink-16.c, could you please help to double check about= it? > Any more information required please feel free to let me know. Thanks. > > compiler error: Segmentation fault > 0x1903067 crash_signal > ../../../../gcc/gcc/toplev.cc:316 > 0x111a24e loop_outer(loop const*) > ../../../../gcc/gcc/cfgloop.h:549 > 0x1ac2143 find_uses_to_rename_use > ../../../../gcc/gcc/tree-ssa-loop-manip.cc:424 > 0x1ac2295 find_uses_to_rename_stmt > ../../../../gcc/gcc/tree-ssa-loop-manip.cc:464 > 0x1ac2456 find_uses_to_rename_bb > ../../../../gcc/gcc/tree-ssa-loop-manip.cc:495 > 0x1ac2585 find_uses_to_rename > ../../../../gcc/gcc/tree-ssa-loop-manip.cc:521 > 0x1ac267c rewrite_into_loop_closed_ssa_1 > ../../../../gcc/gcc/tree-ssa-loop-manip.cc:588 > 0x1ac2735 rewrite_into_loop_closed_ssa(bitmap_head*, unsigned int) > ../../../../gcc/gcc/tree-ssa-loop-manip.cc:628 > 0x19682a3 repair_loop_structures > ../../../../gcc/gcc/tree-cfgcleanup.cc:1190 > 0x196831d cleanup_tree_cfg(unsigned int) > ../../../../gcc/gcc/tree-cfgcleanup.cc:1209 > 0x16e654b execute_function_todo > ../../../../gcc/gcc/passes.cc:2057 > 0x16e534d do_per_function > ../../../../gcc/gcc/passes.cc:1687 > 0x16e68b0 execute_todo > ../../../../gcc/gcc/passes.cc:2142 > > Pan > > -----Original Message----- > From: Richard Biener > Sent: Monday, December 4, 2023 7:54 PM > To: gcc-patches@gcc.gnu.org > Subject: [PATCH] tree-optimization/112827 - corrupt SCEV cache during SCCP > > The following avoids corrupting the SCEV cache by my last change > to propagate constant final values immediately. The easiest fix > is to keep a dead initialization around. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > PR tree-optimization/112827 > * tree-scalar-evolution.cc (final_value_replacement_loop): > Do not release SSA name but keep a dead initialization around. > > * gcc.dg/torture/pr112827-1.c: New testcase. > * gcc.dg/torture/pr112827-2.c: Likewise. > --- > gcc/testsuite/gcc.dg/torture/pr112827-1.c | 14 ++++++++++++++ > gcc/testsuite/gcc.dg/torture/pr112827-2.c | 18 ++++++++++++++++++ > gcc/tree-scalar-evolution.cc | 9 +++------ > 3 files changed, 35 insertions(+), 6 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/torture/pr112827-1.c > create mode 100644 gcc/testsuite/gcc.dg/torture/pr112827-2.c > > diff --git a/gcc/testsuite/gcc.dg/torture/pr112827-1.c > b/gcc/testsuite/gcc.dg/torture/pr112827-1.c > new file mode 100644 > index 00000000000..6838cbbe62f > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/torture/pr112827-1.c > @@ -0,0 +1,14 @@ > +/* { dg-do compile } */ > + > +int a, b, c, d, e; > +int main() { > + for (; c; c++) { > + for (a =3D 0; a < 2; a++) > + ; > + for (; b; b++) { > + e =3D d; > + d =3D a; > + } > + } > + return 0; > +} > diff --git a/gcc/testsuite/gcc.dg/torture/pr112827-2.c > b/gcc/testsuite/gcc.dg/torture/pr112827-2.c > new file mode 100644 > index 00000000000..a7a2a70211b > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/torture/pr112827-2.c > @@ -0,0 +1,18 @@ > +/* { dg-do compile } */ > + > +short a, b[1], f; > +char c, g; > +int d, e; > +int main() { > + for (; f; f++) { > + for (d =3D 0; d < 2; d++) > + ; > + if (a) > + for (g =3D 0; g < 2; g++) > + for (c =3D 0; c < 2; c +=3D b[d+g]) > + ; > + for (; e; e++) > + ; > + } > + return 0; > +} > diff --git a/gcc/tree-scalar-evolution.cc b/gcc/tree-scalar-evolution.cc > index 065bcd0743d..7556d89e9f8 100644 > --- a/gcc/tree-scalar-evolution.cc > +++ b/gcc/tree-scalar-evolution.cc > @@ -3847,13 +3847,10 @@ final_value_replacement_loop (class loop *loop) > def =3D unshare_expr (def); > remove_phi_node (&psi, false); > > - /* Propagate constants immediately. */ > + /* Propagate constants immediately, but leave an unused > initialization > + around to avoid invalidating the SCEV cache. */ > if (CONSTANT_CLASS_P (def)) > - { > - replace_uses_by (rslt, def); > - release_ssa_name (rslt); > - continue; > - } > + replace_uses_by (rslt, def); > > /* Create the replacement statements. */ > gimple_seq stmts; > -- > 2.35.3 > --000000000000244e2c060bbe3487--