[llvm] [AArch64][SME] Remove immediate argument restriction for svldr and svstr (PR #68565)

Kerry McLaughlin via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 07:50:33 PDT 2023


================
@@ -9665,18 +9665,34 @@ Value *CodeGenFunction::EmitSMEZero(const SVETypeFlags &TypeFlags,
 Value *CodeGenFunction::EmitSMELdrStr(const SVETypeFlags &TypeFlags,
                                       SmallVectorImpl<Value *> &Ops,
                                       unsigned IntID) {
-  if (Ops.size() == 3) {
-    Function *Cntsb = CGM.getIntrinsic(Intrinsic::aarch64_sme_cntsb);
-    llvm::Value *CntsbCall = Builder.CreateCall(Cntsb, {}, "svlb");
-    llvm::Value *MulVL = Builder.CreateMul(
-        CntsbCall,
-        Builder.getInt64(cast<llvm::ConstantInt>(Ops[2])->getZExtValue()),
-        "mulvl");
-
-    Ops[1] = Builder.CreateGEP(Int8Ty, Ops[1], MulVL);
-    Ops[0] = EmitTileslice(Ops[0], Ops[2]);
-    Ops.erase(&Ops[2]);
-  }
+  if (Ops.size() == 2) {
+    // Intrinsics without a vecnum also use this function, so just provide 0
+    Ops.push_back(Ops[1]);
+    Ops[1] = Builder.getInt32(0);
+  } else {
+    int Imm = -1;
+    if (ConstantInt* C = dyn_cast<ConstantInt>(Ops[2]))
+      if (C->getZExtValue() <= 15)
+          Imm = C->getZExtValue();
+
+    if (Imm != -1) {
+      Ops[2] = Ops[1];
+      Ops[1] = Builder.getInt32(Imm);
----------------
kmclaughlin-arm wrote:

Would it be possible to remove the check for -1 with something like this?
```
} else if (ConstantInt* C = dyn_cast<ConstantInt>(Ops[2])) {
  auto Imm = C->getZExtValue();
  if (Imm <= 15) {
    Ops[2] = Ops[1];
    Ops[1] = Builder.getInt32(Imm);
}
```

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


More information about the llvm-commits mailing list