From dd68669b66008ab4d8af324b1db3f187133e746b Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Tue, 18 Apr 2017 11:31:30 -0600 Subject: [PATCH] re PR middle-end/80422 (ICE on valid code at -O3 in 32-bit mode on x86_64-linux-gnu: in operator[], at vec.h:732) 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. From-SVN: r246975 --- gcc/ChangeLog | 6 +++++ gcc/cfgcleanup.c | 5 ++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.c-torture/compile/pr80422.c | 26 +++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr80422.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 38c0d301765..67751810e4a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-04-18 Jeff Law + + PR middle-end/80422 + * cfgcleanup.c (try_crossjump_to_edge): Verify SRC1 and SRC2 have + predecessors after walking up the insn chain. + 2017-04-18 Jakub Jelinek PR debug/80263 diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index d55b0ceb832..f68a964e31e 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/ChangeLog b/gcc/testsuite/ChangeLog index 4157094c399..cf5d0be6da3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-18 Jeff Law + + PR middle-end/80422 + * gcc.c-torture/compile/pr80422.c: New test. + 2017-04-18 Jakub Jelinek PR debug/80263 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 00000000000..2cece6775dd --- /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; +} -- 2.30.2