This is an archive of the discontinued LLVM Phabricator instance.

RegisterCoalescer: Avoid redundant implicit-def on rematerialize
ClosedPublic

Authored by arsenm on Jul 26 2023, 9:35 AM.

Details

Summary

If this was coalescing a def of a subregister with a def of the super
register, it was introducing a redundant super-register def and
marking the subregister def as dead.

Resulting in something like:

dead $eax = MOVr0, implicit-def $rax, implicit-def $rax

Avoid this by checking if the new instruction already has the super
def, so we end up with this instead:

dead $eax = MOVr0, implicit-def $rax

The dead flag looks suspicious to me, seems like it's easy to buggily
interpret dead def of subreg and a non-dead def of an aliasing
register. It seems to be intentional though.

Diff Detail