aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/shrink-wrap.c2
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr98289.c52
-rw-r--r--gcc/testsuite/gcc.target/i386/pr98289.c54
3 files changed, 107 insertions, 1 deletions
diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index d70635e..4bb63e9 100644
--- a/gcc/shrink-wrap.c
+++ b/gcc/shrink-wrap.c
@@ -494,7 +494,7 @@ can_get_prologue (basic_block pro, HARD_REG_SET prologue_clobbered)
edge e;
edge_iterator ei;
FOR_EACH_EDGE (e, ei, pro->preds)
- if (e->flags & (EDGE_COMPLEX | EDGE_CROSSING)
+ if (e->flags & EDGE_COMPLEX
&& !dominated_by_p (CDI_DOMINATORS, e->src, pro))
return false;
diff --git a/gcc/testsuite/gcc.dg/torture/pr98289.c b/gcc/testsuite/gcc.dg/torture/pr98289.c
new file mode 100644
index 0000000..07094a1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr98289.c
@@ -0,0 +1,52 @@
+/* PR rtl-optimization/98289 */
+/* { dg-do compile { target freorder } } */
+/* { dg-options "-O2 -freorder-blocks-and-partition" } */
+
+int bar (void) __attribute__((cold));
+
+void
+foo (int x)
+{
+ if (x)
+ __builtin_abort ();
+}
+
+void
+baz (int x)
+{
+ if (__builtin_expect (x, 0))
+ {
+ bar ();
+ bar ();
+ bar ();
+ }
+}
+
+void
+qux (int x, int y, int z, int w)
+{
+ if (x || y || z || w)
+ __builtin_abort ();
+}
+
+int
+corge (int x, int y, int z, int w, int u)
+{
+ if (__builtin_expect (x, 0))
+ goto lab;
+ u++;
+ if (__builtin_expect (y, 0))
+ goto lab;
+ u *= 2;
+ if (__builtin_expect (z, 0))
+ goto lab;
+ u |= 42;
+ if (__builtin_expect (w, 0))
+ {
+ lab:;
+ bar ();
+ bar ();
+ if (bar () > 32) goto lab;
+ }
+ return u;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr98289.c b/gcc/testsuite/gcc.target/i386/pr98289.c
new file mode 100644
index 0000000..9c620d4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr98289.c
@@ -0,0 +1,54 @@
+/* PR rtl-optimization/98289 */
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-require-effective-target freorder } */
+/* { dg-options "-O2 -freorder-blocks-and-partition -fdump-rtl-pro_and_epilogue-details" } */
+/* { dg-final { scan-rtl-dump-times "Performing shrink-wrapping" 4 "pro_and_epilogue" } } */
+
+int bar (void) __attribute__((cold));
+
+void
+foo (int x)
+{
+ if (x)
+ __builtin_abort ();
+}
+
+void
+baz (int x)
+{
+ if (__builtin_expect (x, 0))
+ {
+ bar ();
+ bar ();
+ bar ();
+ }
+}
+
+void
+qux (int x, int y, int z, int w)
+{
+ if (x || y || z || w)
+ __builtin_abort ();
+}
+
+int
+corge (int x, int y, int z, int w, int u)
+{
+ if (__builtin_expect (x, 0))
+ goto lab;
+ u++;
+ if (__builtin_expect (y, 0))
+ goto lab;
+ u *= 2;
+ if (__builtin_expect (z, 0))
+ goto lab;
+ u |= 42;
+ if (__builtin_expect (w, 0))
+ {
+ lab:;
+ bar ();
+ bar ();
+ if (bar () > 32) goto lab;
+ }
+ return u;
+}