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 1F26B3857B84 for ; Mon, 4 Jul 2022 07:09:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F26B3857B84 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 E1FCB22B89 for ; Mon, 4 Jul 2022 07:09:12 +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 D00F013451 for ; Mon, 4 Jul 2022 07:09:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /UQIMRiSwmLkGQAAMHmgww (envelope-from ) for ; Mon, 04 Jul 2022 07:09:12 +0000 Date: Mon, 4 Jul 2022 09:09:12 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106055 - issue with autopar MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220704070912.D00F013451@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 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: Mon, 04 Jul 2022 07:09:15 -0000 When autopar uses graphites canonicalize_loop_closed_ssa it fails to check whether propagation is allowed and thus it ends up messing up abnormal constraints. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2022-07-01 Richard Biener PR tree-optimization/106055 * graphite.cc (canonicalize_loop_closed_ssa): Check whether we can propagate. * gcc.dg/graphite/pr106055.c: New testcase. --- gcc/graphite.cc | 5 ++- gcc/testsuite/gcc.dg/graphite/pr106055.c | 41 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/graphite/pr106055.c diff --git a/gcc/graphite.cc b/gcc/graphite.cc index a88b13c0219..fd4f7a126e1 100644 --- a/gcc/graphite.cc +++ b/gcc/graphite.cc @@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-loop-manip.h" #include "tree-ssa.h" #include "tree-into-ssa.h" +#include "tree-ssa-propagate.h" #include "graphite.h" /* Print global statistics to FILE. */ @@ -337,7 +338,9 @@ canonicalize_loop_closed_ssa (loop_p loop, edge e) /* Iterate over the next phis and remove duplicates. */ gsi_next (&gsi); while (!gsi_end_p (gsi)) - if (gimple_phi_arg_def (phi, 0) == gimple_phi_arg_def (gsi.phi (), 0)) + if (gimple_phi_arg_def (phi, 0) == gimple_phi_arg_def (gsi.phi (), 0) + && may_propagate_copy (gimple_phi_result (gsi.phi ()), + gimple_phi_result (phi))) { replace_uses_by (gimple_phi_result (gsi.phi ()), gimple_phi_result (phi)); diff --git a/gcc/testsuite/gcc.dg/graphite/pr106055.c b/gcc/testsuite/gcc.dg/graphite/pr106055.c new file mode 100644 index 00000000000..22be62b3607 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr106055.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -floop-parallelize-all -fno-tree-dce" } */ + +__attribute__ ((returns_twice)) int +bar (void); + +void +quux (void); + +void +empty (void) +{ +} + +unsigned int +choose (unsigned int x, unsigned int y) +{ + return y ? x : 0; +} + +int +foo (int *p, unsigned int x, int y) +{ + unsigned int acc = 0; + + empty (); + + while (x) + { + bar (); + ++x; + } + + while (y) + acc += y; + + *p = choose (acc, 1); + quux (); + + return x; +} -- 2.35.3