https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88904
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I think the right fix is something like: --- gcc/cfgcleanup.c.jj 2019-01-01 12:37:19.147942300 +0100 +++ gcc/cfgcleanup.c 2019-01-21 16:35:00.737320489 +0100 @@ -338,6 +338,13 @@ thread_jump (edge e, basic_block b) insn != NEXT_INSN (BB_END (b)) && !failed; insn = NEXT_INSN (insn)) { + /* cond2 must not mention any register that is not equal to the + former block. Check this before processing that instruction, + as BB_END (b) could contain also clobbers. */ + if (insn == BB_END (b) + && mentions_nonequal_regs (cond2, nonequal)) + goto failed_exit; + if (INSN_P (insn)) { rtx pat = PATTERN (insn); @@ -362,11 +369,6 @@ thread_jump (edge e, basic_block b) goto failed_exit; } - /* cond2 must not mention any register that is not equal to the - former block. */ - if (mentions_nonequal_regs (cond2, nonequal)) - goto failed_exit; - EXECUTE_IF_SET_IN_REG_SET (nonequal, 0, i, rsi) goto failed_exit; i.e. verify the condition before processing the second conditional jump, because it is evaluated with the state of registers before the instruction, rather than after it.