Undo multi-word optional reloads correctly
authorAlexandre Oliva <oliva@adacore.com>
Wed, 2 Mar 2022 17:13:06 +0000 (14:13 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Wed, 2 Mar 2022 17:13:06 +0000 (14:13 -0300)
commit12f8dc0b642db5edc702f252af1a5231606b29db
tree76ed9d7ed0b6eeedaacac523fa0a609a569e4328
parentdbaabd06aaf4a1b0f2a20671c39148a0bd6ccf0e
Undo multi-word optional reloads correctly

Unlike e.g. remove_inheritance_pseudos, undo_optional_reloads didn't
deal with subregs, so instead of removing multi-word moves, it
replaced the reload pseudo with the original pseudo.  Besides the
redundant move, that retained the clobber of the dest, that starts a
multi-word move.  After the remap, the sequence that should have
become a no-op move starts by clobbering the original pseudo and then
moving its pieces onto themselves.  The problem is the clobber: it
makes earlier sets of the original pseudo to be regarded as dead: if
the optional reload sequence was an output reload, the insn for which
the output reload was attempted may be regarded as dead and deleted.

I've arranged for undo_optional_reloads to accept SUBREGs and use
get_regno, like remove_inheritance_pseudo, adjusted its insn-removal
loop to tolerate iterating over a removed clobber, and added logic to
catch any left-over reload clobbers that could trigger the problem.

for  gcc/ChangeLog

* lra-constraints.cc (undo_optional_reloads): Recognize and
drop insns of multi-word move sequences, tolerate removal
iteration on an already-removed clobber, and refuse to
substitute original pseudos into clobbers.
gcc/lra-constraints.cc