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 775053858CDA for ; Fri, 7 Oct 2022 12:27:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 775053858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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 4AA3F21A11 for ; Fri, 7 Oct 2022 12:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1665145619; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=vO9tljZyfvWxZ+O/9W5ffTepkqrEOi7QiC48DKCzQuc=; b=NMchSz/UL21gB7olkpKzglNg7LUvw8tE8r7IPPJD8I3+OB3Brq/E+2yI05t56Y4pof2lvx qsI02rfkQFTWVjNqcZqqNIKZTQv9AbrZx/ptCX6NLEU/t+9KW8Z7EVuItlL7geJ9Jtrdnb W265i2HRo2pxqLK7eMmBGL8OT6deNl8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1665145619; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=vO9tljZyfvWxZ+O/9W5ffTepkqrEOi7QiC48DKCzQuc=; b=C55CgvqROZ39vSYwGJksyWduc3cFjt8b9x9VjuAyu8e6PCXJJavCezQ7+Eu0S8qpE3YWHZ GEFSl1NcEnbymIAA== 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 274CA13A3D for ; Fri, 7 Oct 2022 12:26:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id PW7KBhMbQGPvXQAAMHmgww (envelope-from ) for ; Fri, 07 Oct 2022 12:26:59 +0000 Date: Fri, 7 Oct 2022 14:26:56 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/107153 - autopar SSA update issue MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20221007122659.274CA13A3D@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 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: 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. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 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. --- 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(-) create mode 100644 gcc/testsuite/gcc.dg/autopar/pr107153.c 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); -- 2.35.3