Message ID | 23d4bf7e-c5c6-e07f-5287-f0c9b1f4bc1b@redhat.com |
---|---|
State | New |
Headers | show |
On Mon, Apr 17, 2017 at 10:20:28AM -0600, Jeff Law wrote: > PR middle-end/80422 > * cfgcleanup.c (try_crossjump_to_edge): Verify SRC1 and SRC2 have > predecessors after walking up the insn chain. > > > PR middle-end/80422 > * gcc.c-torture/compile/pr80422.c: New test. Ok, thanks. > diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c > index d55b0ce..f68a964 100644 > --- a/gcc/cfgcleanup.c > +++ b/gcc/cfgcleanup.c > @@ -2017,6 +2017,11 @@ try_crossjump_to_edge (int mode, edge e1, edge e2, > if (newpos2 != NULL_RTX) > src2 = BLOCK_FOR_INSN (newpos2); > > + /* Check that SRC1 and SRC2 have preds again. They may have changed > + above due to the call to flow_find_cross_jump. */ > + if (EDGE_COUNT (src1->preds) == 0 || EDGE_COUNT (src2->preds) == 0) > + return false; > + > if (dir == dir_backward) > { > #define SWAP(T, X, Y) do { T tmp = (X); (X) = (Y); (Y) = tmp; } while (0) Jakub
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index d55b0ce..f68a964 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -2017,6 +2017,11 @@ try_crossjump_to_edge (int mode, edge e1, edge e2, if (newpos2 != NULL_RTX) src2 = BLOCK_FOR_INSN (newpos2); + /* Check that SRC1 and SRC2 have preds again. They may have changed + above due to the call to flow_find_cross_jump. */ + if (EDGE_COUNT (src1->preds) == 0 || EDGE_COUNT (src2->preds) == 0) + return false; + if (dir == dir_backward) { #define SWAP(T, X, Y) do { T tmp = (X); (X) = (Y); (Y) = tmp; } while (0) diff --git a/gcc/testsuite/gcc.c-torture/compile/pr80422.c b/gcc/testsuite/gcc.c-torture/compile/pr80422.c new file mode 100644 index 0000000..2cece67 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr80422.c @@ -0,0 +1,26 @@ + +int a, c, f; +short b, d, e; + +int fn1 (int h) +{ + return a > 2 || h > a ? h : h << a; +} + +void fn2 () +{ + int j, k; + while (1) + { + k = c && b; + f &= e > (fn1 (k) && j); + if (!d) + break; + } +} + +int main () +{ + fn2 (); + return 0; +}