Hi Eric, The problem shows in loop-doloop.c when I introduce a loop end pattern that replaces the first jump instruction (JUMP_INSN 15) with a pattern that clobbers CC reg. However, the DF doesn't look like it works as the doloop step cannot find the CC reg alive. Please see loop-doloop.c:766. Hence, it introduces the doloop_end patterns, and renders the compare instruction (INSN 14) dead code. leading to errors.
Thanks, Claudiu On Thu, Dec 8, 2022 at 1:33 PM Eric Botcazou <botca...@adacore.com> wrote: > > > However, after this optimization I get the CC reg being dead after > > JUMP_INSN 15, which may lead to wrong code gen. Here it is the dump > > from fwprop1: > > > > (insn 14 11 15 3 (set (reg:CC 66 cc) > > (compare:CC (reg/v:SI 98 [ bytes ]) > > (const_int 8 [0x8]))) "bad_cc.c":11:8 406 {cmpsi} > > (nil)) > > (jump_insn 15 14 16 3 (set (pc) > > (if_then_else (gtu (reg:CC 66 cc) > > (const_int 0 [0])) > > (label_ref 27) > > (pc))) "bad_cc.c":11:8 15 {condjump} > > (expr_list:REG_DEAD (reg:CC 66 cc) > > (int_list:REG_BR_PROB 955630228 (nil))) > > -> 27) > > (note 16 15 18 4 [bb 4] NOTE_INSN_BASIC_BLOCK) > > (jump_insn 18 16 19 4 (set (pc) > > (if_then_else (eq (reg:CC 66 cc) > > (const_int 0 [0])) > > (label_ref:DI 34) > > (pc))) "bad_cc.c":12:10 15 {condjump} > > (expr_list:REG_DEAD (reg:CC 66 cc) > > (int_list:REG_BR_PROB 365072228 (nil))) > > -> 34) > > > > Please observe the REG_DEAD note on the both jump instructions. > > Passes that consume REG_DEAD/REG_UNUSED notes need to recompute them > explicitly, they are not updated on the fly. > > -- > Eric Botcazou > >