This is an archive of the discontinued LLVM Phabricator instance.

Pass LiveIntervals to foldMemoryOperandImpl(), to enable checking of liveness of preg (flag reg).
ClosedPublic

Authored by jonpa on May 3 2016, 5:02 AM.

Details

Reviewers
MatzeB
Summary

SystemZ (and probably other targets as well) can fold a memory operand by changing the opcode into a new instruction that as a side-effect also clobbers the CC-reg.

In order to do this, liveness of that reg must first be checked.

When LIS is passed, getRegUnit() can be called on it and the right LiveRange is computed on demand.

(originated on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-April/098301.html)

Diff Detail

Event Timeline

jonpa updated this revision to Diff 55971.May 3 2016, 5:02 AM
jonpa retitled this revision from to Pass LiveIntervals to foldMemoryOperandImpl(), to enable checking of liveness of preg (flag reg)..
jonpa updated this object.
jonpa added a reviewer: MatzeB.
jonpa added subscribers: uweigand, llvm-commits.
jonpa updated this revision to Diff 55979.May 3 2016, 5:54 AM

Also re-enable test case for the LA -> AGSI optimization that has been temporarily disabled until this is resolved.

MatzeB edited edge metadata.May 3 2016, 11:24 AM

Looks good in principle, but I am pretty sure you did not even compile this. (Invalid call as below, no target except SystemZ adapted).

lib/CodeGen/InlineSpiller.cpp
764–765

huh, does this compile with 3 arguments to the first foldMemoryOperand() call?

lib/Target/SystemZ/SystemZInstrInfo.cpp
864–865

You should add an assert here that SystemZ::CC does indeed only have a single register unit.

MatzeB added inline comments.May 3 2016, 11:28 AM
lib/Target/SystemZ/SystemZInstrInfo.cpp
866

This needs a .getRegSlot() added.

jonpa added a comment.May 4 2016, 9:57 AM

I did compile it - but only for SystemZ so far. I will fix other targets as well - but let me first await your answer on the overloaded method.. Should that be extended also, you think (see comment)?

lib/CodeGen/InlineSpiller.cpp
764–765

Yes - thats a different (overloaded) method. Perhaps this should also be extended with LIS in the same way, for sake of conformity?

MatzeB added a comment.May 4 2016, 1:52 PM

I did compile it - but only for SystemZ so far. I will fix other targets as well - but let me first await your answer on the overloaded method.. Should that be extended also, you think (see comment)?

Yes please go ahead.

lib/CodeGen/InlineSpiller.cpp
764–765

Oh that is confusing. We should rename one of them instead of overloading, but that is for a different patch. Yep it sounds sensible to add the extra parameter to both.

jonpa updated this revision to Diff 56528.May 8 2016, 11:41 PM
jonpa edited edge metadata.

Other targets methods modified as well.

I realized that LIS may not actually be available (e.g. when called from X86::optimizeLoadInstr()), so I changed the LIS argument into a pointer type with default value of nullptr.

Not sure if there is a better way to assert for single reg unit in SystemZInstrInfo::foldMemoryOperandImpl()?

Not sure if there is / should be a simpler way of checking liveness of a register at the point of an instruction. For example LIS->isRegisterLiveAtInstruction(SystemZ::CC, MI) and LIS->createDeadDefAt(System::CC, MI)?

MatzeB accepted this revision.May 9 2016, 10:47 AM
MatzeB edited edge metadata.

Other targets methods modified as well.

I realized that LIS may not actually be available (e.g. when called from X86::optimizeLoadInstr()), so I changed the LIS argument into a pointer type with default value of nullptr.

LGTM

Not sure if there is a better way to assert for single reg unit in SystemZInstrInfo::foldMemoryOperandImpl()?

I don't know of any better either.

Not sure if there is / should be a simpler way of checking liveness of a register at the point of an instruction. For example LIS->isRegisterLiveAtInstruction(SystemZ::CC, MI) and LIS->createDeadDefAt(System::CC, MI)?

isRegisterLiveAtInstruction() would be too simplistic. Look at the existing LiveRange::Query() which gathers all liveness related information you may need about an instruction. We could add a convenience function around that (in another patch) though I I personally didn't miss it much and often needed the SlotIndex, LiveInterval anyway so the convenience method wouldn't have helped.

This revision is now accepted and ready to land.May 9 2016, 10:47 AM
jonpa closed this revision.May 10 2016, 1:17 AM

Thanks for review, Matthias.

Commited as r269026.