This is an archive of the discontinued LLVM Phabricator instance.

[PPC64] Use mfocrf in prologue when we only need to save 1 nonvolatile CR field
ClosedPublic

Authored by cycheng on Feb 29 2016, 8:25 PM.

Details

Summary

In the ELFv2 ABI, we are not required to save all CR fields. If only one nonvolatile CR field is clobbered, use mfocrf instead of mfcr to selectively save the field, because mfocrf has short latency compares to mfcr.

Diff Detail

Event Timeline

cycheng updated this revision to Diff 49447.Feb 29 2016, 8:25 PM
cycheng retitled this revision from to [PPC64] Use mfocrf in prologue when we only need to save 1 nonvolatile CR field.
cycheng updated this object.
cycheng added reviewers: nemanjai, tjablin, kbarton, hfinkel.
cycheng added a subscriber: llvm-commits.
nemanjai added inline comments.Mar 1 2016, 12:17 AM
lib/Target/PowerPC/PPCFrameLowering.cpp
849

Do we not want to do this if we're serializing the CR/LR save sequences (i.e. when the prologue has a single scratch register available)? Perhaps define MfcrOpcode above and use it here as well.

test/CodeGen/PowerPC/crsave.ll
25

Do we not know which CR field we need to save here?

cycheng updated this revision to Diff 49469.Mar 1 2016, 3:23 AM
cycheng marked 2 inline comments as done.
  • Also use MfcrOpcode checking in the CR/LR serializing case
  • Only do this for ELFv2ABI
  • Fix test case
lib/Target/PowerPC/PPCFrameLowering.cpp
849

Thanks : ) I fixed it.

By the way, I am curious about in which circumstance TempReg == ScratchReg? Because of shrink-wrapping?

test/CodeGen/PowerPC/crsave.ll
25

Yes we know it.

nemanjai added inline comments.Mar 1 2016, 4:23 AM
lib/Target/PowerPC/PPCFrameLowering.cpp
849

Yes. When we sink the prologue into the function for shrink wrapping and the BB has only one available register we use that register to save both the CR and the LR.

kbarton accepted this revision.Apr 1 2016, 1:42 PM
kbarton edited edge metadata.

LGTM

This revision is now accepted and ready to land.Apr 1 2016, 1:42 PM
cycheng closed this revision.Apr 11 2016, 8:20 PM

Committed r266038.