https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99927
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- It indeed goes wrong in the 105, 107 -> 108 try_combine, but at the start of that we have: (insn 105 23 106 6 (set (reg:QI 135) (const_int 1 [0x1])) "pr99927.c":13:24 77 {*movqi_internal} (nil)) (note 106 105 107 6 NOTE_INSN_DELETED) (insn 107 106 108 6 (set (reg:CCZ 17 flags) (compare:CCZ (reg:SI 107) (const_int 0 [0]))) "pr99927.c":13:24 7 {*cmpsi_ccno_1} (nil)) (insn 108 107 111 6 (set (reg:QI 96 [ var_lsm_flag.12 ]) (if_then_else:QI (eq (reg:CCZ 17 flags) (const_int 0 [0])) (subreg:QI (reg:SI 107) 0) (reg:QI 135))) "pr99927.c":13:24 1104 {*movqicc_noc} (expr_list:REG_DEAD (reg:SI 107) (expr_list:REG_DEAD (reg:CC 17 flags) (nil)))) (insn 111 108 85 6 (set (reg:QI 96 [ var_lsm_flag.12 ]) (if_then_else:QI (eq (reg:CCZ 17 flags) (const_int 0 [0])) (reg:QI 96 [ var_lsm_flag.12 ]) (reg:QI 135))) "pr99927.c":13:24 1104 {*movqicc_noc} (expr_list:REG_DEAD (reg:QI 135) (nil))) (jump_insn 85 111 35 6 (set (pc) (if_then_else (ne (reg:CCZ 17 flags) (const_int 0 [0])) (label_ref 45) (pc))) 806 {*jcc} (expr_list:REG_DEAD (reg:CCZ 17 flags) (int_list:REG_BR_PROB 536870916 (nil))) -> 45) The substitutions of 105 and 107 into 108 properly simplify 108 into (set (reg:QI 96 [ var_lsm_flag.12 ]) (subreg:QI (reg:SI 107) 0)) because it is: (set (reg:QI 96 [ var_lsm_flag.12 ]) (if_then_else:QI (ne (reg:SI 107) (const_int 0 [0])) (const_int 1 [0x1]) (const_int 0 [0]))) But what is wrong is that try_combine has been called at all, because (reg:CCZ 17 flags) is used in 3 instructions rather than just one.