From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id C35FF3853547 for ; Wed, 13 Jul 2022 07:35:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C35FF3853547 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 48CC922468 for ; Wed, 13 Jul 2022 07:35:44 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 35A3E13AAD for ; Wed, 13 Jul 2022 07:35:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id p8EBDNB1zmI9IAAAMHmgww (envelope-from ) for ; Wed, 13 Jul 2022 07:35:44 +0000 Date: Wed, 13 Jul 2022 09:35:43 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106249 - unroll-and-jam and LC SSA upate MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220713073544.35A3E13AAD@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 07:35:48 -0000 When I delayed the LC SSA update in unroll-and-jam this exposed an issue that tree_transform_and_unroll_loop does a full function LC SSA verification when new_loop is NULL (when it doesn't need to do versioning). That wasn't intended. I also took the chance to make the versioning in tree_transform_and_unroll_loop use TODO_update_ssa_nophi for the loop versioning SSA update which I somehow missed earlier. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/106249 * tree-ssa-loop-manip.cc (tree_transform_and_unroll_loop): Only verify LC SSA of the new_loop if we created it. Use TODO_update_ssa_nophi for the SSA update after versioning the loop. * gcc.dg/pr106249.c: New testcase. --- gcc/testsuite/gcc.dg/pr106249.c | 16 ++++++++++++++++ gcc/tree-ssa-loop-manip.cc | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr106249.c diff --git a/gcc/testsuite/gcc.dg/pr106249.c b/gcc/testsuite/gcc.dg/pr106249.c new file mode 100644 index 00000000000..f97b07fb4da --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106249.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -floop-unroll-and-jam --param unroll-jam-min-percent=0" } */ + +void +foo (double *arr) +{ + int i, j; + + for (i = 0; i < 4; ++i) + for (j = 0; j < 4; ++j) + arr[j] = 0; + + for (i = 1; i < 4; ++i) + for (j = 0; j < 4; ++j) + arr[j] = 1.0 / (i + 1); +} diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc index c531f1f12fd..410a8516370 100644 --- a/gcc/tree-ssa-loop-manip.cc +++ b/gcc/tree-ssa-loop-manip.cc @@ -1208,7 +1208,7 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor, profile_probability::guessed_always (), true); gcc_assert (new_loop != NULL); - update_ssa (TODO_update_ssa); + update_ssa (TODO_update_ssa_no_phi); /* Prepare the cfg and update the phi nodes. Move the loop exit to the loop latch (and make its condition dummy, for the moment). */ @@ -1428,7 +1428,8 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor, checking_verify_flow_info (); checking_verify_loop_structure (); checking_verify_loop_closed_ssa (true, loop); - checking_verify_loop_closed_ssa (true, new_loop); + if (new_loop) + checking_verify_loop_closed_ssa (true, new_loop); } /* Wrapper over tree_transform_and_unroll_loop for case we do not -- 2.35.3