https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121852
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So we have
q ={v} 5;
q.2_19 ={v} q;
_20 = 5 % q.2_19;
...
_5 = 1 % m.9_4;
_6 = _3 - _5;
t_16 = _6 + 1;
o.10_8 = o;
_9 = 2 % t_16;
The volatile mess hides from GIMPLE but not RTL optimizers that there is 5 % 5
and
cse1 "helpfully" optimizes the 1 in 1 % m.9_4 to the result of 5 / 5.
And we get there the stale REG_UNUSED:
(insn 37 36 38 5 (parallel [
(set (reg:SI 132)
(div:SI (reg/v:SI 119 [ q ])
(reg/v:SI 119 [ q ])))
(set (reg:SI 131 [ _26 ])
(mod:SI (reg/v:SI 119 [ q ])
(reg/v:SI 119 [ q ])))
(clobber (reg:CC 17 flags))
]) "pr121852.c":14:9 676 {*divmodsi4}
(expr_list:REG_DEAD (reg:SI 130)
(expr_list:REG_DEAD (reg:SI 113 [ q.2_25 ])
(expr_list:REG_UNUSED (reg:SI 132)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))))
...
(insn 55 54 56 6 (parallel [
(set (reg:SI 141)
(div:SI (reg:SI 132)
(reg:SI 101 [ m.9_4 ])))
(set (reg:SI 140 [ _5 ])
(mod:SI (reg:SI 132)
(reg:SI 101 [ m.9_4 ])))
(clobber (reg:CC 17 flags))
]) "pr121852.c":24:15 676 {*divmodsi4}
(expr_list:REG_DEAD (reg:SI 139)
(expr_list:REG_DEAD (reg:SI 101 [ m.9_4 ])
(expr_list:REG_UNUSED (reg:SI 141)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(nil))))))
Generally, CSE and forwprop are examples of passes which can invalidate
REG_UNUSED notes.
And then something during loop_unroll drops the whole insn 37 and various
others without replacement.
So, either we need to drop all REG_UNUSED/REG_DEAD notes at the end of the cse
passes and perhaps a few others, or arrange for the next pass after those to
recompute those, or adjust them whenever we extend the lifetime.