summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
diff options
context:
space:
mode:
authorAmy Kwan <amy.kwan1@ibm.com>2019-11-24 00:27:40 -0600
committerAmy Kwan <amy.kwan1@ibm.com>2019-11-24 00:27:40 -0600
commitd1dded28da2808200dacdc1eda46058cc0a0759b (patch)
treee1fa6407e2b77c0e04607ee6255d342ff91c30e9 /llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
parente0297a8bee6586280640f31b876d4da15966f8b7 (diff)
downloadbcm5719-llvm-d1dded28da2808200dacdc1eda46058cc0a0759b.tar.gz
bcm5719-llvm-d1dded28da2808200dacdc1eda46058cc0a0759b.zip
[PowerPC] Spill CR LT bits on P9 using setb
This patch aims to spill CR[0-7]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 Differential Revision: https://reviews.llvm.org/D68443
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
index 90193c2e9e0..032e3a92063 100644
--- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -787,6 +787,21 @@ void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II,
SpillsKnownBit = true;
break;
default:
+ // 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).
+ if (Subtarget.isISA3_0()) {
+ if (SrcReg == PPC::CR0LT || SrcReg == PPC::CR1LT ||
+ SrcReg == PPC::CR2LT || SrcReg == PPC::CR3LT ||
+ SrcReg == PPC::CR4LT || SrcReg == PPC::CR5LT ||
+ SrcReg == PPC::CR6LT || SrcReg == PPC::CR7LT) {
+ BuildMI(MBB, II, dl, TII.get(LP64 ? PPC::SETB8 : PPC::SETB), Reg)
+ .addReg(getCRFromCRBit(SrcReg), RegState::Undef);
+ break;
+ }
+ }
+
// We need to move the CR field that contains the CR bit we are spilling.
// The super register may not be explicitly defined (i.e. it can be defined
// by a CR-logical that only defines the subreg) so we state that the CR
OpenPOWER on IntegriCloud