[llvm] [RISCV] Add custom lowering for fixed-vector `CLMUL`/`CLMULH` (PR #210429)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 22:51:56 PDT 2026


================
@@ -1725,6 +1725,20 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
                 Custom);
         }
 
+        if (VT.getVectorElementType() == MVT::i64) {
+          if (Subtarget.hasStdExtZvbc())
+            setOperationAction({ISD::CLMUL, ISD::CLMULH}, VT, Custom);
+        } else {
+          if (Subtarget.hasStdExtZvbc32e()) {
+            setOperationAction({ISD::CLMUL, ISD::CLMULH}, VT, Custom);
+          } else if (Subtarget.hasStdExtZvbc()) {
+            // Promote to i64 like in the case of scalable vectors.
+            if (useRVVForFixedLengthVectorVT(
+                    VT.changeVectorElementType(MVT::i64)))
----------------
lukel97 wrote:

The RVV intrinsics tests are failing, I think it's because of this line. changeVectorElementType asserts when the type isn't valid, so I think you want to do `MVT::getVectorVT(MVT::i64, VT.getVectorElementCount())` and check if it's valid first instead

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


More information about the llvm-commits mailing list