This is an archive of the discontinued LLVM Phabricator instance.

[LiveIntervals] Improve repair after convertToThreeAddress
ClosedPublic

Authored by foad on Sep 23 2021, 8:08 AM.

Details

Summary

After TwoAddressInstructionPass calls
TargetInstrInfo::convertToThreeAddress, improve the LiveIntervals repair
to cope with convertToThreeAddress creating more than one new
instruction.

This mostly seems to benefit X86. For example in
test/CodeGen/X86/zext-trunc.ll it converts:

%4:gr32 = ADD32rr %3:gr32(tied-def 0), %2:gr32, implicit-def dead $eflags

to:

undef %6.sub_32bit:gr64 = COPY %3:gr32
undef %7.sub_32bit:gr64_nosp = COPY %2:gr32
%4:gr32 = LEA64_32r killed %6:gr64, 1, killed %7:gr64_nosp, 0, $noreg

Diff Detail

Event Timeline

foad created this revision.Sep 23 2021, 8:08 AM
foad requested review of this revision.Sep 23 2021, 8:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 23 2021, 8:08 AM

Hey!

This mostly seems to benefit X86

What benefits are we about here?
Is it compile time?

Cheers,
-Quentin

foad added a comment.Sep 24 2021, 11:05 AM

What benefits are we about here?
Is it compile time?

Good question. It is mostly about reviving an incomplete transition from LiveVariables to LiveIntervals, as described here (thread): https://lists.llvm.org/pipermail/llvm-dev/2013-February/059261.html

LiveIntervals have good support for tracking subregister liveness information as described here (thread): https://lists.llvm.org/pipermail/llvm-dev/2013-October/066176.html

My motivation for working on this is that I have recently run into cases where TwoAddressInstructionPass is doing a poor job because it is relying on kill flags, which only relate to a whole "superregister", instead of fine grained subregister liveness. The best way to fix this seems to be to complete the transition to LiveIntervals. It's easy to test by forcing -early-live-intervals on. I don't know what the compile time impact will be yet.

foad added a comment.Sep 24 2021, 11:13 AM

This mostly seems to benefit X86

What benefits are we about here?
Is it compile time?

At this stage I'm just trying to fix various crashes caused by -early-live-intervals, so I just meant that this patch mostly fixes crashes in X86 test cases.

qcolombet accepted this revision.Sep 27 2021, 4:43 PM

Makes sense, thanks!

This revision is now accepted and ready to land.Sep 27 2021, 4:43 PM
This revision was landed with ongoing or failed builds.Sep 28 2021, 12:20 AM
This revision was automatically updated to reflect the committed changes.