public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9211] tree-optimization/97627 - Avoid computing niters for fake edges
@ 2021-01-29 11:51 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-01-29 11:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a7e6e7a9299208e5aa3d805d502370d59f92b8b5
commit r9-9211-ga7e6e7a9299208e5aa3d805d502370d59f92b8b5
Author: Richard Biener <rguenther@suse.de>
Date: Fri Jan 29 11:17:42 2021 +0100
tree-optimization/97627 - Avoid computing niters for fake edges
This avoids computing niters information for fake edges.
2021-01-29 Bin Cheng <bin.cheng@linux.alibaba.com>
Richard Biener <rguenther@suse.de>
PR tree-optimization/97627
* tree-ssa-loop-niter.c (number_of_iterations_exit_assumptions):
Do not analyze fake edges.
* g++.dg/pr97627.C: New testcase.
(cherry picked from commit 3976b2701b826569ffcd90877d94095def507e3f)
Diff:
---
gcc/testsuite/g++.dg/pr97627.C | 44 ++++++++++++++++++++++++++++++++++++++++++
gcc/tree-ssa-loop-niter.c | 5 +++++
2 files changed, 49 insertions(+)
diff --git a/gcc/testsuite/g++.dg/pr97627.C b/gcc/testsuite/g++.dg/pr97627.C
new file mode 100644
index 00000000000..81466dc3b81
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr97627.C
@@ -0,0 +1,44 @@
+/* PR tree-optimization/97627. */
+/* { dg-do run } */
+
+struct S { unsigned short x, y; } m = { 1, 0 };
+
+__attribute__((noipa)) void
+baz (int x, int y)
+{
+ if (x != 0 || y != 1)
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) void
+bar ()
+{
+ throw 1;
+}
+
+void
+foo ()
+{
+ while (1)
+ {
+ int a = m.x + 1;
+ int b = m.y + 1;
+ for (int c = 0; c < a; c++)
+ for (int d = 0; d < b; d++)
+ baz (d, b);
+ bar ();
+ }
+}
+
+int
+main ()
+{
+ try
+ {
+ foo ();
+ }
+ catch (int)
+ {
+ }
+ return 0;
+}
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 470b6a295be..200344b42dd 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -2382,6 +2382,11 @@ number_of_iterations_exit_assumptions (struct loop *loop, edge exit,
affine_iv iv0, iv1;
bool safe;
+ /* The condition at a fake exit (if it exists) does not control its
+ execution. */
+ if (exit->flags & EDGE_FAKE)
+ return false;
+
/* Nothing to analyze if the loop is known to be infinite. */
if (loop_constraint_set_p (loop, LOOP_C_INFINITE))
return false;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-29 11:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 11:51 [gcc r9-9211] tree-optimization/97627 - Avoid computing niters for fake edges Richard Biener
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).