On Fri, Dec 13, 2024 at 04:00:38PM -0700, Jeff Law wrote: > On 12/13/24 8:20 AM, Jakub Jelinek wrote: > > The following testcase is miscompiled on s390x-linux with -O2 -march=z15. > > The problem happens during cse2, which sees in an extended basic block > > (jump_insn 217 78 216 10 (parallel [ > > (set (pc) > > (if_then_else (ne (reg:SI 165) > > (const_int 1 [0x1])) > > (label_ref 216) > > (pc))) > > (set (reg:SI 165) > > (plus:SI (reg:SI 165) > > (const_int -1 [0xffffffffffffffff]))) > > (clobber (scratch:SI)) > > (clobber (reg:CC 33 %cc)) > > ]) "t.c":14:17 discrim 1 2192 {doloop_si64} > > (int_list:REG_BR_PROB 955630228 (nil)) > > -> 216) > > ... > > (insn 99 98 100 12 (set (reg:SI 138) > > (const_int 1 [0x1])) "t.c":9:31 1507 {*movsi_zarch} > > (nil)) > > (insn 100 99 103 12 (parallel [ > > (set (reg:SI 137) > > (minus:SI (reg:SI 138) > > (subreg:SI (reg:HI 135 [ a ]) 0))) > > (clobber (reg:CC 33 %cc)) > > ]) "t.c":9:31 1904 {*subsi3} > > (expr_list:REG_DEAD (reg:SI 138) > > (expr_list:REG_DEAD (reg:HI 135 [ a ]) > > (expr_list:REG_UNUSED (reg:CC 33 %cc) > > (nil))))) > I don't really see the connection between (reg 165) and (reg 138), but I > don't think it matters enough to dive into.
The ebb continues after jump_insn 217 when the branch is not taken, i.e. if (ne (reg:SI 165) (const_int 1 [0x1])) is false. As it ignored the r165 -= 1 part of the insn, it recorded (reg:SI 165) must be const1_rtx and (reg:SI 138) is set to the same value, so let's use the older holder of SImode 1 constant instead of a new one... Except that (reg:SI 165) is actually 0 after the doloop insn stops iterating. Jakub