On Sun, Mar 13, 2022 at 02:03:33PM +0100, Eric Botcazou wrote: > > Bootstrapped/regtested on {x86_64,i686,powerpc64le,aarch64,s390x}-linux, > > ok for trunk? > > > > 2022-03-13 Jakub Jelinek <ja...@redhat.com> > > > > PR rtl-optimization/104814 > > * ifcvt.cc (find_if_case_1, find_if_case_2): Punt if test_bb > > doesn't end with onlyjump_p. > > > > * gcc.c-torture/execute/pr104814.c: New test. > > > > --- gcc/ifcvt.cc.jj 2022-02-09 12:55:50.750773751 +0100 > > +++ gcc/ifcvt.cc 2022-03-11 17:30:44.248855063 +0100 > > @@ -5259,6 +5259,10 @@ find_if_case_1 (basic_block test_bb, edg > > && CROSSING_JUMP_P (BB_END (else_bb)))) > > return FALSE; > > > > + /* Verify test_bb ends in a conditional jump with no other side-effects. > > */ + if (!BB_END (test_bb) || !onlyjump_p (BB_END (test_bb))) > > + return FALSE; > > + > > /* THEN has one successor. */ > > if (!single_succ_p (then_bb)) > > return FALSE; > > @@ -5380,6 +5384,10 @@ find_if_case_2 (basic_block test_bb, edg > > && CROSSING_JUMP_P (BB_END (else_bb)))) > > return FALSE; > > > > + /* Verify test_bb ends in a conditional jump with no other side-effects. > > */ + if (!BB_END (test_bb) || !onlyjump_p (BB_END (test_bb))) > > + return FALSE; > > + > > /* ELSE has one successor. */ > > if (!single_succ_p (else_bb)) > > return FALSE; > > Are the !BB_END tests really necessary? cond_exec_process_if_block has the > same test on onlyjump_p without it. Likewise for noce_find_if_block.
Probably not, I've put it there only because the neighboring code is testing it too: if ((BB_END (then_bb) && JUMP_P (BB_END (then_bb)) && CROSSING_JUMP_P (BB_END (then_bb))) || (BB_END (test_bb) && JUMP_P (BB_END (test_bb)) && CROSSING_JUMP_P (BB_END (test_bb))) || (BB_END (else_bb) && JUMP_P (BB_END (else_bb)) && CROSSING_JUMP_P (BB_END (else_bb)))) return FALSE; find_if_header which calls find_if_case_* has: if (EDGE_COUNT (test_bb->succs) != 2) return NULL; at the start, and I think an empty bb can't have more than one successor, because there is nothing to cause different control flow. Jakub