This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Spill CR LT bits on P9 using setb
ClosedPublic

Authored by amyk on Oct 3 2019, 10:10 PM.

Details

Summary

This patch aims to spill CR[0-1]LT bits on POWER9 using the setb instruction.
The sequence on P9 to spill these bits will be:

setb %reg, %CRREG
stw %reg, $FI

Instead of the typical sequence:

mfocrf %reg, %CRREG
rlwinm %reg1, %reg, $SH, 0, 0
stw %reg1, $FI

The number of mfocrf instructions within SPEC 2017 decreases by ~2.6%.

Diff Detail

Event Timeline

amyk created this revision.Oct 3 2019, 10:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 3 2019, 10:10 PM
jsji added a reviewer: Restricted Project.Oct 15 2019, 11:20 AM
NeHuang added inline comments.
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
783

nit: alignment. Two less space before "if"

790

nit: alignment. same as line 783.

kamaub added a subscriber: kamaub.Oct 21 2019, 10:42 AM

Looks good to me, just a note about the summary:

spill CR[0-1]LT bits on POWER9 using the setb instruction

I think you changed the spill for all fields' LT bit as per the if statement so, this might be due for a change.

llvm/test/CodeGen/PowerPC/spill_p9_setb.ll
1

nit: Add a note to describe this test case's purpose

nemanjai accepted this revision.Oct 21 2019, 6:25 PM

LGTM aside from a couple of minor nits that can be addressed on the commit.

llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
781

I think this would benefit from a slightly more elaborate explanation. Perhaps:

// On Power9, we can use SETB to extract the LT bit. This only works for
// the LT bit since SETB produces -1/1/0 for LT/GT/<neither>. So the value
// of the bit we care about (32-bit sign bit) will be set to the value of
// the LT bit (regardless of the other bits in the CR field).
llvm/test/CodeGen/PowerPC/spill_p9_setb.ll
12

Rather than explicitly checking for the new sequence and not the old sequence, please just add a RUN line to this test case that will use -mcpu=pwr8 and produce the checks with the script.

This revision is now accepted and ready to land.Oct 21 2019, 6:25 PM
This revision was automatically updated to reflect the committed changes.
amyk marked 4 inline comments as done.