From patchwork Fri Oct 7 12:26:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp271278wrs; Fri, 7 Oct 2022 05:28:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4svc4vspjL+GJtSiVW0y/I6V9m2/VNT1MzxhvqDWCYcfb5vSWqc11Vi5EINku6zRYs41wc X-Received: by 2002:a05:6402:3208:b0:458:9e25:50d0 with SMTP id g8-20020a056402320800b004589e2550d0mr4250035eda.283.1665145684543; Fri, 07 Oct 2022 05:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665145684; cv=none; d=google.com; s=arc-20160816; b=MaPjGsAlKsMReKCIuEdwP1sXMPoOwqU0p7E7uvBCYspUFLJyR90uL61iYIbTLmIcGl AL4egE3KWcHPeBa3DD0EomEggQaKZstoYqJXC9uDHUdw5RBoZ+0Q+D1WxDsH+8TVrF52 mABSi6YhV5OoocRg8Z8rVzndGDG49AgW5fCfvw9KmbHIdacsYJv8MX3nqEX10uM1MRL4 kopJlsf/Ljk/Wok4nB/+ZE3Ze4GRfUJpcHJ9z4Cu0sEKJ8mXK+c8JE4GHY26RWnem2Vr tI3KALtwu5FBLew2TYODrcUUWafTdj1rO8oxDg3AWldnMDR4Gl1Xq+ualV9vcMLXjjEJ gPuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=vO9tljZyfvWxZ+O/9W5ffTepkqrEOi7QiC48DKCzQuc=; b=TxbmKFqAftZ1l2lUD6+4IWRBl1Ao0ANn8/0TVhgaH64l0Is8DPdPodeLC+bcKGKoii 5BXPy6YaUaX+aTHCtWvNqnEwOgc57Agj4jOVxkJBGj6TSqnoBuZ70UExmQ2ToRj3nlct JcvYn+iVnWaLY5smjuYVbVZ1RbUXgIEfeijvyiP81dF0xDyCbJPKJmBIOJOh8ER19MUQ ZsnfLd5emFpFRqJ5m5hXCcjdmQYtgublL9NjL78HlQFt0NSvW3BcW+O2zFC3DR9Rkbzj oYdRFwNdSC4K9CS8jvnBWD3ZBCL5UoAdPtlSsn4OQOwQOKJLXbz6VN5L68IEZsJbKghr wqcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ISwkF9Sp; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k13-20020a17090666cd00b00781c229eee4si1943124ejp.936.2022.10.07.05.28.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 05:28:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ISwkF9Sp; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EBAF73821FF5 for ; Fri, 7 Oct 2022 12:27:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBAF73821FF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665145679; bh=vO9tljZyfvWxZ+O/9W5ffTepkqrEOi7QiC48DKCzQuc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ISwkF9SpFrVrByvJ3YCBn8u1JMt52WHHX8ypGW3CiSqUbn8f0dEh30cd8En2u/Ltn nrrBfl/3M91/OKo75rXbBokeEMT7kjZLmYRP/2NCWfmKa7NH2MTmp+nrwCh8vttjnZ aBSRSsIIuHnwvH/xtwrOgYmfOQTyXyyNXr8V/+0s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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) 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) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/107153 - autopar SSA update issue MIME-Version: 1.0 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 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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746031801370799918?= X-GMAIL-MSGID: =?utf-8?q?1746031801370799918?= 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);