[llvm] [Codegen] Add a separate stack ID for scalable predicates (PR #142390)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 5 09:30:17 PDT 2025


================
@@ -3495,10 +3494,14 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
     }
     // Update the StackIDs of the SVE stack slots.
     MachineFrameInfo &MFI = MF.getFrameInfo();
-    if (RPI.Type == RegPairInfo::ZPR || RPI.Type == RegPairInfo::PPR) {
+    if (RPI.Type == RegPairInfo::ZPR) {
       MFI.setStackID(FrameIdxReg1, TargetStackID::ScalableVector);
       if (RPI.isPaired())
         MFI.setStackID(FrameIdxReg2, TargetStackID::ScalableVector);
+    } else if (RPI.Type == RegPairInfo::PPR) {
+      MFI.setStackID(FrameIdxReg1, TargetStackID::ScalablePredVector);
+      if (RPI.isPaired())
+        MFI.setStackID(FrameIdxReg2, TargetStackID::ScalablePredVector);
----------------
MacDue wrote:

The stack IDs are _mostly_ for quickly telling what's in a stack slot. In this patch, nothing much is using the `ScalablePredVector` stack ID (mostly just spills/fills added in frame lowering), and everything still ends up in the (single) SVE area.

With split predicates enabled `ScalableVector` and `ScalablePredVector` stack slots are separate regions on the stack. However, until frame lowering most predicate stack slots still use `ScalableVector`, and then during frame lowering we find stack slots that are only accessed with predicate load/store instructions and change the stack ID to `ScalablePredVector`.

> And also, do different stack IDs prevent slot coalescing during stack slot colouring?

I think they would prevent coalescing, but I think in my current patch most uses of the `ScalablePredVector` stack ID are not added until after that pass has already run.  

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


More information about the llvm-commits mailing list