[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
Thu Apr 9 12:10:59 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:
The current test in `amo-enable.ll`, `test_lwat_csne`, has `%ptr` as the first argument so it arrives in R3/X3, which triggers the scavenger path. This is why we see `mr r9, r3` to move ptr from `r3` to `r9` before the first lwat.
https://github.com/llvm/llvm-project/pull/190698
More information about the llvm-commits
mailing list