This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Fix equality for copies from physregs in matchEqualDefs
ClosedPublic

Authored by paquette on Mar 26 2020, 3:11 PM.

Details

Summary

When we see this:

%a = COPY $physreg
...
SOMETHING implicit-def $physreg
...
%b = COPY $physreg

The two copies are not equivalent, and so we shouldn't perform any folding on them.

When we have two instructions which use a physical register check that they define the same virtual register(s) as well.

e.g., if we run into this case

%a = COPY $physreg
...
%b = COPY %a

we can say that the two copies are the same, and can be folded.

Diff Detail

Event Timeline

paquette created this revision.Mar 26 2020, 3:11 PM

No test with the implicit def case you mentioned?

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
1528

ISel should probably not ever think about liveness like this

The existing test had

%a:_(s32) = COPY $w0
%b:_(s32) = COPY $w0

which is no longer folded

but yeah it would probably be better to be clear in the testcase about why this isn't folded, so I'll change it.

paquette updated this revision to Diff 253011.Mar 26 2020, 4:26 PM
  • Remove FIXME, since we don't want to care about register liveness in isel
  • Update testcase so that there's an implicit def between the copies
  • Add another testcase that has a copy between the copies, because that should probably be tested too
arsenm accepted this revision.Mar 27 2020, 2:07 PM

LGTM

llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-select.mir
3–12

The IR section shouldn't be needed?

This revision is now accepted and ready to land.Mar 27 2020, 2:07 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2020, 6:12 PM