[llvm] [PowerPC] Rework AMO load with Compare and Swap Not Equal to use post-RA pseudo expansion (PR #190698)
Maryam Moghadas via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 09:46:19 PDT 2026
================
@@ -5892,3 +5895,42 @@ bool PPCInstrInfo::areMemAccessesTriviallyDisjoint(
}
return false;
}
+
+// Expands LWAT_CSNE_PSEUDO/LDAT_CSNE_PSEUDO post register allocation.
+// lwat/ldat FC=16 requires 3 consecutive registers. X3/X4/X5 are
+// hardcoded post-RA to satisfy this constraint without a dedicated
+// register class.
+bool PPCInstrInfo::expandAMOCSNEPseudo(MachineInstr &MI) const {
+ MachineBasicBlock &MBB = *MI.getParent();
+ DebugLoc DL = MI.getDebugLoc();
+ bool IsLDAT = MI.getOpcode() == PPC::LDAT_CSNE_PSEUDO;
+
+ Register DstReg = MI.getOperand(0).getReg();
+ Register PtrReg = MI.getOperand(1).getReg();
+
+ Register ScratchReg = PtrReg;
+ if (PtrReg == PPC::X3 || PtrReg == PPC::X4 || PtrReg == PPC::X5) {
----------------
maryammo wrote:
> I'd like to see a test where scavenging forces a spill.
Avoided scavenging in expansion as, noted by @RolandF77 , spilling creates conflicting live ranges requiring separate slots per AMO instance. Instead, use $dst as scratch when ptr is R8/R9/R10. Also switched from R3/R4/R5 (heavily used ABI registers) to R8/R9/R10.
https://github.com/llvm/llvm-project/pull/190698
More information about the llvm-commits
mailing list