From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id C676F382F99E; Fri, 7 Oct 2022 12:27:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C676F382F99E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665145673; bh=NCTXZ10rgeu6jirhtFi/KL82XJLmbUlm+6krmJs+MVE=; h=From:To:Subject:Date:From; b=rbDIWC7Fd2Mt9uGFqTe5iVDE+WsujVLsXavBTv5jfrsutq/pMrzzh5712Sc54QuYd 06v41g8xHRbpS62iihxv+DI037Ttb1mbGZ0x1eUC/0HkujQ9d3WTIwuZwG+c4J+/tz x2mTxFqJ0mDVxooZmzokK3dJ/1/esz/QMBCbxKa4= 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-3161] tree-optimization/107153 - autopar SSA update issue X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 6bd2c1231a95e257dd590754430bdb191b3bca11 X-Git-Newrev: 89228e3985c5cdf6be58a3b5b1afcad91e9e3422 Message-Id: <20221007122753.C676F382F99E@sourceware.org> Date: Fri, 7 Oct 2022 12:27:53 +0000 (GMT) List-Id: https://gcc.gnu.org/g:89228e3985c5cdf6be58a3b5b1afcad91e9e3422 commit r13-3161-g89228e3985c5cdf6be58a3b5b1afcad91e9e3422 Author: Richard Biener Date: Fri Oct 7 10:28:56 2022 +0200 tree-optimization/107153 - autopar SSA update issue autopar performs insertion of stores, eventually requiring a virtual loop PHI and assorted LC PHI adjustments which we intend to do once after the pass finishes. But we also perform intermediate update_ssa after loop duplication which can lose this fact. The following forces renaming of the virtual operand before the final SSA update to fix that. It also removes the explicit update_ssa call from the gimple_duplicate_sese_tail utility as has been done for all other such utilities and instead performs the SSA update from autopar. PR tree-optimization/107153 * tree-cfg.cc (gimple_duplicate_sese_tail): Do not update SSA form here. * tree-parloops.cc (gen_parallel_loop): Update SSA form after to-exit-first transform, no PHI insertion is necessary. (pass_parallelize_loops::execute): Force re-write of the virtual operand SSA web. * gcc.dg/autopar/pr107153.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/autopar/pr107153.c | 17 +++++++++++++++++ gcc/tree-cfg.cc | 2 -- gcc/tree-parloops.cc | 5 +++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/autopar/pr107153.c b/gcc/testsuite/gcc.dg/autopar/pr107153.c new file mode 100644 index 00000000000..2391a674d63 --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr107153.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -floop-parallelize-all -ftree-parallelize-loops=2 -fno-tree-dominator-opts" } */ + +void +foo (int x, int y) +{ + int i; + + for (i = 0; i < 2; i++) + { + } + + while (x) + if (!y) + while (y) + ++y; +} diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 09fa7b64584..42f40f17c56 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -6926,8 +6926,6 @@ gimple_duplicate_sese_tail (edge entry, edge exit, /* Anything that is outside of the region, but was dominated by something inside needs to update dominance info. */ iterate_fix_dominators (CDI_DOMINATORS, doms, false); - /* Update the SSA web. */ - update_ssa (TODO_update_ssa); if (free_region_copy) free (region_copy); diff --git a/gcc/tree-parloops.cc b/gcc/tree-parloops.cc index e4a148b5365..e680d97dd04 100644 --- a/gcc/tree-parloops.cc +++ b/gcc/tree-parloops.cc @@ -3131,6 +3131,7 @@ gen_parallel_loop (class loop *loop, to the exit of the loop. */ transform_to_exit_first_loop (loop, reduction_list, nit); } + update_ssa (TODO_update_ssa_no_phi); /* Generate initializations for reductions. */ if (!reduction_list->is_empty ()) @@ -4215,6 +4216,10 @@ pass_parallelize_loops::execute (function *fun) checking_verify_loop_structure (); + /* ??? Intermediate SSA updates with no PHIs might have lost + the virtual operand renaming needed by separate_decls_in_region, + make sure to rename them again. */ + mark_virtual_operands_for_renaming (fun); update_ssa (TODO_update_ssa); if (in_loop_pipeline) rewrite_into_loop_closed_ssa (NULL, 0);