Hi,

in PR 85899 an assert is failing in find_fallthru_edge_from because the code
tries to verify the invariant e->dest == e->src->next_bb for a fallthru edge
and does not anticipate that it will fail if e->dest is the exit block (bb 1):
in this case next_bb is fairly arbitrary (it's just the next bb that appears
in the insn sequence and has nothing to do with the "fake" fallthru to exit).

So it looks to me that the assert has to allow this.  I've bootstrapped the
following (not that it matters much as it simply relaxes the assert) and
verified it fixes the testcase.

OK for trunk?

        * haifa-sched.c (find_fallthru_edge_from): Relax assert to account for
        fallthru edges leading to the exit block.

        * gcc.dg/pr85899.c: New test.

diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 72178b68999..5025aae421d 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -8082,7 +8082,7 @@ find_fallthru_edge_from (basic_block pred)
 
       if (e)
        {
-         gcc_assert (e->dest == succ);
+         gcc_assert (e->dest == succ || e->dest->index == EXIT_BLOCK);
          return e;
        }
     }
diff --git a/gcc/testsuite/gcc.dg/pr85899.c b/gcc/testsuite/gcc.dg/pr85899.c
index e69de29bb2d..eb2b175339c 100644
--- a/gcc/testsuite/gcc.dg/pr85899.c
+++ b/gcc/testsuite/gcc.dg/pr85899.c
@@ -0,0 +1,17 @@
+/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fschedule-insns -fselective-scheduling -funroll-loops 
-fno-gcse -fno-if-conversion -fno-ivopts" } */
+
+#define N 4096
+int cb[N];
+int cc[N];
+int cd[N];
+
+void init ()
+{
+  int i;
+  for (i = 0; i < N; ++i) {
+    cb[i] = 3 * i - 2048;
+    cc[i] = -5 * i + 93;
+    cd[i] = i % 2 ? 1 : -1;
+  }
+}

Reply via email to