https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
void m() {
int aa = 0, i = 0;
for (; i < 3; i++)
if (k < 0)
aa |= *j;
Dump of assembler code for function m:
0x0000000000400540 <+0>: mov 0x200b16(%rip),%edi # 0x60105c
<k>
0x0000000000400546 <+6>: mov 0x200b13(%rip),%rax # 0x601060
<j>
0x000000000040054d <+13>: sar $0x1f,%edi
=> 0x0000000000400550 <+16>: and (%rax),%edi
0x0000000000400552 <+18>: cmpw $0x0,0x200af6(%rip) # 0x601050
<d>
so we're loading *j before checking k < 0. On GIMPLE that's OK:
<bb 2> [local count: 268435456]:
k.5_1 = k;
j.6_2 = j;
if (k.5_1 < 0)
goto <bb 3>; [41.00%]
else
goto <bb 4>; [59.00%]
<bb 3> [local count: 110058537]:
j.6__lsm0.31_28 = *j.6_2;
<bb 4> [local count: 268435456]:
# aa_9 = PHI <j.6__lsm0.31_28(3), 0(2)>
but RTL if-conversion makes the load unconditional.
(insn 13 12 35 3 (set (reg/v:SI 89 [ j.6__lsm0.31 ])
(mem:SI (reg/f:DI 83 [ j.6_2 ]) [1 *j.6_2+0 S4 A32])) 77
{*movsi_internal}
(expr_list:REG_DEAD (reg/f:DI 83 [ j.6_2 ])
(nil)))
I don't see any flags marking it as not trapping?