From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/106055 - issue with autopar
Date: Mon, 4 Jul 2022 09:09:12 +0200 (CEST) [thread overview]
Message-ID: <20220704070912.D00F013451@imap2.suse-dmz.suse.de> (raw)
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 <rguenther@suse.de>
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
reply other threads:[~2022-07-04 7:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220704070912.D00F013451@imap2.suse-dmz.suse.de \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).