[llvm] [RISCV] Promote i8/i16/i32 scalable vector CLMUL to i64 CLMUL with Zvbc. (PR #184265)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 08:56:28 PST 2026


================
@@ -1117,8 +1117,19 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
         }
       }
 
-      if (Subtarget.hasStdExtZvbc() && VT.getVectorElementType() == MVT::i64)
-        setOperationAction({ISD::CLMUL, ISD::CLMULH}, VT, Legal);
+      if (Subtarget.hasStdExtZvbc() && Subtarget.hasVInstructionsI64()) {
+        // TODO: Support Zvbc32e.
+        if (VT.getVectorElementType() == MVT::i64)
+          setOperationAction({ISD::CLMUL, ISD::CLMULH}, VT, Legal);
+        else {
+          // Promote to i64 if the lmul is small enough.
+          // FIXME: Split if necessary to widen.
+          // FIXME: Promote clmulh directly without legalizing to clmul first.
+          MVT I64VecVT = MVT::getVectorVT(MVT::i64, VT.getVectorElementCount());
+          if (isTypeLegal(I64VecVT))
----------------
topperc wrote:

It fails the lit tests because there isn't an i64 MVT for all of the possble element counts here. changeVectorElementType isn't allowed to create an illegal MVT.

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


More information about the llvm-commits mailing list