[llvm] [AArch64] Update Cost model for CLMUL (PR #202965)

Matthew Devereau via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 04:53:21 PDT 2026


================
@@ -635,6 +635,56 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
       return HistCost;
     break;
   }
+  case Intrinsic::clmul: {
+    auto LT = getTypeLegalizationCost(RetTy);
+
+    // PMUL v8i8/v16i8 is always available on AArch64
+    if (ST->hasNEON()) {
+      if (LT.second == MVT::v8i8 || LT.second == MVT::v16i8)
+        return LT.first;
+
+      // Scalar i8 lowers through scalar/vector moves around PMUL.
+      if (TLI->getValueType(DL, RetTy, true) == MVT::i8)
+        return 4;
+    }
+
+    if (ST->hasSVE2() || ST->hasSME()) {
----------------
MDevereau wrote:

I had a go at it but it looked horrendous with the special cases mixed in. I also realised nxv2i64 with +sve and +sve,+sve+aes were costed incorrectly because it was marking them as +2 since they go through to custom lowering. In reality +sve's nxv2i64 lowering is bad, and +sve+sve-aes is 3 vector ops.

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


More information about the llvm-commits mailing list