Hi! As the testcase shows, if more than one conditional trap is turned into non-conditional during one_cprop_pass in a single bb, we only split the bb after the first one (because the rest is going to be removed as unreachable), but before that happens, we trigger RTL verification that complains that there is unconditional trap in the middle of a bb.
The following patch fixes it by turning the second and following trap into NOTE_INSN_DELETED, so that the verification is happy about it and we can safely remove the bb as unreachable afterwards. Bootstrapped/regtested on powerpc64-linux (tested with --target_board=unix\{,-m32\}) with yes,rtl,extra checking, ok for trunk? 2017-03-02 Jakub Jelinek <ja...@redhat.com> PR rtl-optimization/79780 * cprop.c (one_cprop_pass): When second and further conditional trap in a single basic block is turned into an unconditional trap, turn it into a deleted note to avoid RTL verification failures. * gcc.c-torture/compile/pr79780.c: New test. --- gcc/cprop.c.jj 2017-02-13 22:55:30.000000000 +0100 +++ gcc/cprop.c 2017-03-01 20:53:04.611430286 +0100 @@ -1852,12 +1852,22 @@ one_cprop_pass (void) if (! NOTE_P (insn) && ! insn->deleted ()) mark_oprs_set (insn); - if (!was_uncond_trap && !seen_uncond_trap + if (!was_uncond_trap && GET_CODE (PATTERN (insn)) == TRAP_IF && XEXP (PATTERN (insn), 0) == const1_rtx) { - seen_uncond_trap = true; - uncond_traps.safe_push (insn); + /* If we have already seen an unconditional trap + earlier, the rest of the bb is going to be removed + as unreachable. Just turn it into a note, so that + RTL verification doesn't complain about it before + it is finally removed. */ + if (seen_uncond_trap) + set_insn_deleted (insn); + else + { + seen_uncond_trap = true; + uncond_traps.safe_push (insn); + } } } } --- gcc/testsuite/gcc.c-torture/compile/pr79780.c.jj 2017-03-01 21:00:56.231240727 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr79780.c 2017-03-01 21:00:17.000000000 +0100 @@ -0,0 +1,48 @@ +/* PR rtl-optimization/79780 */ + +int t3, iy, f4, oi, gn; + +void +foo (long long int mh) +{ + int pi = 0; + + if (iy != 0) + for (;;) + f4 = 0; + + if (t3 != 0) + { + while (mh != 0LL) + { + while (mh < 1LL) + ++mh; + ++mh; + } + for (;;) + ; + for (oi = 0; oi < 1; ++oi) + { + n3:; + } + gn = iy = 1; + } + + f4 = 0; + + if (pi - (mh != 0LL) == 0) + if (mh != 1LL) + { + oi = t3 = 0; + if (mh == 0LL) + ++pi; + } + + if (iy != 0 && pi != 0) + { + t3 = 0; + goto n3; + } + + t3 /= 0; +} Jakub