[llvm] [AArch64][SVE] Pair SVE fill/spill into LDP/STP with -msve-vector-bits=128. (PR #134068)

Ricardo Jesus via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 8 08:23:26 PDT 2025


================
@@ -1227,6 +1231,15 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
     (void)MIBSXTW;
     LLVM_DEBUG(dbgs() << "  Extend operand:\n    ");
     LLVM_DEBUG(((MachineInstr *)MIBSXTW)->print(dbgs()));
+  } else if (Opc == AArch64::LDR_ZXI || Opc == AArch64::STR_ZXI) {
+    // We are combining SVE fill/spill to LDP/STP, so we need to use the Q
+    // variant of the registers.
+    MachineOperand &MOp0 = MIB->getOperand(0);
+    MachineOperand &MOp1 = MIB->getOperand(1);
+    assert(AArch64::ZPRRegClass.contains(MOp0.getReg()) &&
+           AArch64::ZPRRegClass.contains(MOp1.getReg()) && "Invalid register.");
+    MOp0.setReg(AArch64::Q0 + (MOp0.getReg() - AArch64::Z0));
+    MOp1.setReg(AArch64::Q0 + (MOp1.getReg() - AArch64::Z0));
----------------
rj-jesus wrote:

I think the reason I didn't place this earlier is that the machine verifier segfaults in `verifyUseList` if I do so, although I believe it should work if I create a copy of the operands (say, with MachineOperand::CreateReg) instead of using `setReg`. 

For now I've just added the missing debug message, but please let me know if you'd like it done differently.

https://github.com/llvm/llvm-project/pull/134068


More information about the llvm-commits mailing list