From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 16EBD3857BAB; Thu, 4 Aug 2022 13:01:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16EBD3857BAB MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1961] tree-optimization/106521 - unroll-and-jam LC SSA rewrite X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: d86d81a449c03641e079f23a2b3e1b2279a162fe X-Git-Newrev: d8552eaddc40b72461158e56b5db8709f2eb21ed Message-Id: <20220804130153.16EBD3857BAB@sourceware.org> Date: Thu, 4 Aug 2022 13:01:53 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2022 13:01:53 -0000 https://gcc.gnu.org/g:d8552eaddc40b72461158e56b5db8709f2eb21ed commit r13-1961-gd8552eaddc40b72461158e56b5db8709f2eb21ed Author: Richard Biener Date: Thu Aug 4 11:55:15 2022 +0200 tree-optimization/106521 - unroll-and-jam LC SSA rewrite The LC SSA rewrite performs SSA verification at start but the VN run performed on the unrolled-and-jammed body can leave us with invalid SSA form until CFG cleanup is run. So make sure we do that before rewriting into LC SSA. PR tree-optimization/106521 * gimple-loop-jam.cc (tree_loop_unroll_and_jam): Perform CFG cleanup manually before rewriting into LC SSA. * gcc.dg/torture/pr106521.c: New testcase. Diff: --- gcc/gimple-loop-jam.cc | 10 +++++++++- gcc/testsuite/gcc.dg/torture/pr106521.c | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-loop-jam.cc b/gcc/gimple-loop-jam.cc index 8cde6c7c5ce..a8a57d3d384 100644 --- a/gcc/gimple-loop-jam.cc +++ b/gcc/gimple-loop-jam.cc @@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-loop-ivopts.h" #include "tree-vectorizer.h" #include "tree-ssa-sccvn.h" +#include "tree-cfgcleanup.h" /* Unroll and Jam transformation @@ -609,9 +610,16 @@ tree_loop_unroll_and_jam (void) if (todo) { + free_dominance_info (CDI_DOMINATORS); + /* We need to cleanup the CFG first since otherwise SSA form can + be not up-to-date from the VN run. */ + if (todo & TODO_cleanup_cfg) + { + cleanup_tree_cfg (); + todo &= ~TODO_cleanup_cfg; + } rewrite_into_loop_closed_ssa (NULL, 0); scev_reset (); - free_dominance_info (CDI_DOMINATORS); } return todo; } diff --git a/gcc/testsuite/gcc.dg/torture/pr106521.c b/gcc/testsuite/gcc.dg/torture/pr106521.c new file mode 100644 index 00000000000..05c8ce54d0b --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr106521.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-floop-unroll-and-jam --param unroll-jam-min-percent=0" } */ + +short a, b, e; +volatile long c; +long d; +int main() { + for (; d; d++) { + long g = a = 1; + for (; a; a++) { + g++; + c; + } + g && (b = e); + } + return 0; +}