On 8/15/24 2:45 AM, Richard Sandiford wrote:
When it removes a definition, late-combine tries to update all
uses in notes.  It does this using the same insn_propagation class
that it uses for patterns.

However, insn_propagation uses validate_change, which in turn
resets the INSN_CODE.  This is inefficient in the best case,
since it forces the pattern to be rerecognised even though
changing a note can't affect the INSN_CODE.  But in the PR
it's a correctness problem: resetting INSN_CODE means we lose
the NOOP_INSN_MOVE_CODE, which in turn means that rtl-ssa doesn't
queue it for deletion.

This patch adds a routine specifically for propagating into notes.
A belt-and-braces fix would be to rerecognise noop moves in
function_info::change_insns, but I can't think of a good reason
why that would be necessary, and it could paper over latent bugs.

Tested on aarch64-linux-gnu & x86_64-linux-gnu.  OK to install?

Richard


gcc/
        PR testsuite/116343
        * recog.h (insn_propagation::apply_to_note): Declare.
        * recog.cc (insn_propagation::apply_to_note): New function.
        * late-combine.cc (insn_combination::substitute_note): Use
        apply_to_note instead of apply_to_rvalue.
        * rtl-ssa/changes.cc (rtl_ssa::changes_are_worthwhile): Improve
        dumping of costs for noop moves.
Having fought problems with changing INSN_CODEs and rerecognition, I've wondered if we really should have an API for that to always put things back the way they were. Though I guess in this case and the one I looked at likely wouldn't want to use the same API. So perhaps not a great idea.


OK

jeff

Reply via email to