-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[PowerPC][NFC] Update lowering STXVP to STXV in Oct word spilling #142220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-powerpc Author: Lei Huang (lei137) ChangesRemove explicit register arithmetic from spilling ACC and STXVP code. Full diff: https://github.com/llvm/llvm-project/pull/142220.diff 1 Files Affected:
diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
index 51902ad218d1c..7c0d2e0dbec27 100644
--- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -1238,42 +1238,6 @@ static void emitAccSpillRestoreInfo(MachineBasicBlock &MBB, bool IsPrimed,
#endif
}
-static void spillRegPairs(MachineBasicBlock &MBB,
- MachineBasicBlock::iterator II, DebugLoc DL,
- const TargetInstrInfo &TII, Register SrcReg,
- unsigned FrameIndex, bool IsLittleEndian,
- bool IsKilled, bool TwoPairs) {
- unsigned Offset = 0;
- // The register arithmetic in this function does not support virtual
- // registers.
- assert(!SrcReg.isVirtual() &&
- "Spilling register pairs does not support virtual registers.");
-
- if (TwoPairs)
- Offset = IsLittleEndian ? 48 : 0;
- else
- Offset = IsLittleEndian ? 16 : 0;
- Register Reg = (SrcReg > PPC::VSRp15) ? PPC::V0 + (SrcReg - PPC::VSRp16) * 2
- : PPC::VSL0 + (SrcReg - PPC::VSRp0) * 2;
- addFrameReference(BuildMI(MBB, II, DL, TII.get(PPC::STXV))
- .addReg(Reg, getKillRegState(IsKilled)),
- FrameIndex, Offset);
- Offset += IsLittleEndian ? -16 : 16;
- addFrameReference(BuildMI(MBB, II, DL, TII.get(PPC::STXV))
- .addReg(Reg + 1, getKillRegState(IsKilled)),
- FrameIndex, Offset);
- if (TwoPairs) {
- Offset += IsLittleEndian ? -16 : 16;
- addFrameReference(BuildMI(MBB, II, DL, TII.get(PPC::STXV))
- .addReg(Reg + 2, getKillRegState(IsKilled)),
- FrameIndex, Offset);
- Offset += IsLittleEndian ? -16 : 16;
- addFrameReference(BuildMI(MBB, II, DL, TII.get(PPC::STXV))
- .addReg(Reg + 3, getKillRegState(IsKilled)),
- FrameIndex, Offset);
- }
-}
-
/// Remove any STXVP[X] instructions and split them out into a pair of
/// STXV[X] instructions if --disable-auto-paired-vec-st is specified on
/// the command line.
@@ -1290,8 +1254,21 @@ void PPCRegisterInfo::lowerOctWordSpilling(MachineBasicBlock::iterator II,
Register SrcReg = MI.getOperand(0).getReg();
bool IsLittleEndian = Subtarget.isLittleEndian();
bool IsKilled = MI.getOperand(0).isKill();
- spillRegPairs(MBB, II, DL, TII, SrcReg, FrameIndex, IsLittleEndian, IsKilled,
- /* TwoPairs */ false);
+
+ assert(PPC::VSRpRCRegClass.contains(SrcReg) &&
+ "Expecting STXVP to be utilizing a VSRp register.");
+
+ addFrameReference(
+ BuildMI(MBB, II, DL, TII.get(PPC::STXV))
+ .addReg(TargetRegisterInfo::getSubReg(SrcReg, PPC::sub_vsx0),
+ getKillRegState(IsKilled)),
+ FrameIndex, IsLittleEndian ? 16 : 0);
+ addFrameReference(
+ BuildMI(MBB, II, DL, TII.get(PPC::STXV))
+ .addReg(TargetRegisterInfo::getSubReg(SrcReg, PPC::sub_vsx1),
+ getKillRegState(IsKilled)),
+ FrameIndex, IsLittleEndian ? 0 : 16);
+
// Discard the original instruction.
MBB.erase(II);
}
@@ -1325,8 +1302,6 @@ void PPCRegisterInfo::lowerACCSpilling(MachineBasicBlock::iterator II,
bool IsKilled = MI.getOperand(0).isKill();
bool IsPrimed = PPC::ACCRCRegClass.contains(SrcReg);
- Register Reg =
- PPC::VSRp0 + (SrcReg - (IsPrimed ? PPC::ACC0 : PPC::UACC0)) * 2;
bool IsLittleEndian = Subtarget.isLittleEndian();
emitAccSpillRestoreInfo(MBB, IsPrimed, false);
@@ -1337,16 +1312,34 @@ void PPCRegisterInfo::lowerACCSpilling(MachineBasicBlock::iterator II,
// adjust the offset of the store that is within the 64-byte stack slot.
if (IsPrimed)
BuildMI(MBB, II, DL, TII.get(PPC::XXMFACC), SrcReg).addReg(SrcReg);
- if (DisableAutoPairedVecSt)
- spillRegPairs(MBB, II, DL, TII, Reg, FrameIndex, IsLittleEndian, IsKilled,
- /* TwoPairs */ true);
- else {
- addFrameReference(BuildMI(MBB, II, DL, TII.get(PPC::STXVP))
- .addReg(Reg, getKillRegState(IsKilled)),
- FrameIndex, IsLittleEndian ? 32 : 0);
- addFrameReference(BuildMI(MBB, II, DL, TII.get(PPC::STXVP))
- .addReg(Reg + 1, getKillRegState(IsKilled)),
- FrameIndex, IsLittleEndian ? 0 : 32);
+ if (DisableAutoPairedVecSt) {
+ auto spillPair = [&](Register Reg, int Offset) {
+ addFrameReference(
+ BuildMI(MBB, II, DL, TII.get(PPC::STXV))
+ .addReg(TargetRegisterInfo::getSubReg(Reg, PPC::sub_vsx0),
+ getKillRegState(IsKilled)),
+ FrameIndex, Offset);
+ addFrameReference(
+ BuildMI(MBB, II, DL, TII.get(PPC::STXV))
+ .addReg(TargetRegisterInfo::getSubReg(Reg, PPC::sub_vsx1),
+ getKillRegState(IsKilled)),
+ FrameIndex, IsLittleEndian ? Offset - 16 : Offset + 16);
+ };
+ spillPair(TargetRegisterInfo::getSubReg(SrcReg, PPC::sub_pair0),
+ IsLittleEndian ? 48 : 0);
+ spillPair(TargetRegisterInfo::getSubReg(SrcReg, PPC::sub_pair1),
+ IsLittleEndian ? 16 : 32);
+ } else {
+ addFrameReference(
+ BuildMI(MBB, II, DL, TII.get(PPC::STXVP))
+ .addReg(TargetRegisterInfo::getSubReg(SrcReg, PPC::sub_pair0),
+ getKillRegState(IsKilled)),
+ FrameIndex, IsLittleEndian ? 32 : 0);
+ addFrameReference(
+ BuildMI(MBB, II, DL, TII.get(PPC::STXVP))
+ .addReg(TargetRegisterInfo::getSubReg(SrcReg, PPC::sub_pair1),
+ getKillRegState(IsKilled)),
+ FrameIndex, IsLittleEndian ? 0 : 32);
}
if (IsPrimed && !IsKilled)
BuildMI(MBB, II, DL, TII.get(PPC::XXMTACC), SrcReg).addReg(SrcReg);
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp View the diff from clang-format here.diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
index 9dc69e203..a3a8eea33 100644
--- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -1256,7 +1256,7 @@ void PPCRegisterInfo::lowerOctWordSpilling(MachineBasicBlock::iterator II,
bool IsKilled = MI.getOperand(0).isKill();
assert(PPC::VSRpRCRegClass.contains(SrcReg) &&
- "Expecting STXVP to be utilizing a VSRp register.");
+ "Expecting STXVP to be utilizing a VSRp register.");
addFrameReference(
BuildMI(MBB, II, DL, TII.get(PPC::STXV))
|
9fbf355
to
407bc35
Compare
gentle ping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
407bc35
to
5f1a84d
Compare
…ling (llvm#142220)" This reverts commit edf636a. Checked in the wrong branch.
…ling (llvm#142220)" This reverts commit edf636a.
I accidentally pushed the wrong branch |
…pilling (#143953) Simpliy handling for spilling of acc reg with stx by removing explicit register arithmetic and clean up code gen for register mapping used in stxvp spilling. Relanding: llvm/llvm-project#142220
…vm#142220) Remove explicit register arithmetic from spilling ACC and STXVP code.
llvm#143948) …ling (llvm#142220)" This reverts commit edf636a. checked in wrong branch.
…vm#143953) Simpliy handling for spilling of acc reg with stx by removing explicit register arithmetic and clean up code gen for register mapping used in stxvp spilling. Relanding: llvm#142220
…vm#142220) Remove explicit register arithmetic from spilling ACC and STXVP code.
llvm#143948) …ling (llvm#142220)" This reverts commit edf636a. checked in wrong branch.
…vm#143953) Simpliy handling for spilling of acc reg with stx by removing explicit register arithmetic and clean up code gen for register mapping used in stxvp spilling. Relanding: llvm#142220
Remove explicit register arithmetic from spilling ACC and STXVP code.