On 17/11/20 02:12, Jeff Law wrote:
Removing all REG_EQUAL notes for regs that become dead anywhere

That's not what it does.

seems to just be a thinko?  All pseudos are dead somewhere!  (Yeah okay,
infinite loops, but other than that.)

Yea, but the code which wipes the notes probably has no sense of where
in the RTL stream the note is valid and where it is not.  So it does the
fairly dumb thing and just ends up wiping them all away because as you
noted, most pseudos have a death somewhere.

It shouldn't wipe all of them. It doesn't look at all REG_EQUAL notes in the function; it looks at the notes one insn at a time, and wipes the REG_EQUAL notes for registers that are dead _at that insn_. See how the loop uses DF_INSN_EQ_USES:

           for (use_rec = DF_INSN_EQ_USES (insn); *use_rec; use_rec++)
             {
               df_ref use = *use_rec;
               if (DF_REF_REGNO (use) > FIRST_PSEUDO_REGISTER
                   && (DF_REF_FLAGS (use) & DF_REF_IN_NOTE)
                   && ! bitmap_bit_p (live, DF_REF_REGNO (use)))
                 {
                   deleted = true;
                   break;
                 }
             }

and it is called as

      df_kill_notes (insn, live);

One might argue that the code is OK as-is, but just needs to be run
later.  After cse2 would be the most logical location since CSE is
probably the heaviest user of the notes.  But I'd worry that the
problems referenced in c#2 of bz51505 could crop up in other contexts
than just combine.

Yeah, it was a design decision of DF to ignore REG_EQUAL/REG_EQUIV notes when computing liveness and adding REG_DEAD notes[1]. Unfortunately this all predates my involvement in DF and I'm also unfamiliar with how REG_DEAD and REG_EQUAL notes interacted in flow.c times. But it's very unlikely that after ~10 years there aren't more places with the same issue that PR51505 worked around.

Paolo

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51505#c3

Reply via email to