Hi! On the (undefined behavior) testcase below, we end up with then_bb ending with __builtin_unreachable () at the tree level, therefore no successor at the RTL level, and else_bb being EXIT_BLOCK_PTR (i.e. conditional return before a bb with undefined behavior at the end). Trying to optimize that into a conditional execution of the then_bb insns doesn't work, we can't merge the else_bb with then_bb and test_bb in this case, plus it doesn't look like something that would be desirable to do (conditional return is surely better).
Fixed thusly, ok for trunk/4.8? 2013-04-02 Jakub Jelinek <ja...@redhat.com> PR rtl-optimization/56745 * ifcvt.c (cond_exec_find_if_block): Don't try to optimize if then_bb has no successors and else_bb is EXIT_BLOCK_PTR. * gcc.c-torture/compile/pr56745.c: New test. --- gcc/ifcvt.c.jj 2013-03-05 23:25:15.000000000 +0100 +++ gcc/ifcvt.c 2013-04-02 12:31:19.476859094 +0200 @@ -3473,7 +3473,7 @@ cond_exec_find_if_block (struct ce_if_bl code processing. ??? we should fix this in the future. */ if (EDGE_COUNT (then_bb->succs) == 0) { - if (single_pred_p (else_bb)) + if (single_pred_p (else_bb) && else_bb != EXIT_BLOCK_PTR) { rtx last_insn = BB_END (then_bb); --- gcc/testsuite/gcc.c-torture/compile/pr56745.c.jj 2013-04-02 12:38:54.718258527 +0200 +++ gcc/testsuite/gcc.c-torture/compile/pr56745.c 2013-04-02 12:33:22.000000000 +0200 @@ -0,0 +1,15 @@ +/* PR rtl-optimization/56745 */ + +unsigned char a[6]; + +void +foo () +{ + int i; + for (i = 5; i >= 0; i++) + { + if (++a[i] != 0) + break; + ++a[i]; + } +} Jakub