https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121648

--- Comment #6 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
(In reply to Sam James from comment #5)
> (In reply to Andrew Pinski from comment #3)
> > My gut feeling is this is another REG_UNUSED issue but I could be wrong.
> > The div/mod here is an important.
> 
> It used DF before r11-6188-g0b76990a9d75d9, so it might be exposing another
> pass not keeping notes up to date.
Yeah, I think it's both of the above.  cse1 is entered with duplicate div/mods,
one where the mod is unused and one where the div is unused.  cse1 reuses the
mod result of the former, but leaves the REG_UNUSED in place.  Then the use of
the div result is replaced with an earlier division result, leaving the div/mod
seemingly dead, even though the mod result is still used.

On trunk, the testcase fails even with fwprop disabled
(-fdisable-rtl-fwprop{1,2}).  It passes with -fdisable-rtl-loop2_invariant.  So
the pass that exposes the problem is somewhat arbitrary.

The difficulty, of course, is that passes aren't expected to keep REG_DEAD and
REG_UNUSED notes up to date.  They're supposed to be recomputed by passes that
need them.  But the heavily used single_set tests REG_UNUSED under the hood.

There have been several PRs about this before.  It's all a bit of a mess.

Reply via email to