[llvm] Add EVT::changeVectorElementCount and MVT:changeVectorElementCount (PR #182266)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 19 05:48:13 PST 2026


================
@@ -108,6 +108,29 @@ namespace llvm {
       return getVectorVT(Context, EltVT, getVectorElementCount());
     }
 
+    /// Return a VT for a vector type whose attributes match ourselves with
+    /// the exception of the element count that is chosen by the caller.
+    EVT changeVectorElementCount(LLVMContext &Context, ElementCount EC) const {
+      if (isSimple()) {
+        MVT M = MVT::getVectorVT(getSimpleVT(), EC);
+        if (M != MVT::INVALID_SIMPLE_VALUE_TYPE)
+          return M;
+      }
+      return getVectorVT(Context, getVectorElementType(), EC);
+    }
+
+    /// Return a VT for a vector type whose attributes match ourselves with
+    /// the exception of the number of elements that is chosen by the caller.
+    EVT changeVectorNumElements(LLVMContext &Context, unsigned NumElements,
----------------
RKSimon wrote:

drop this - we're trying to use ElementCount whenever possible - changeVectorElementCount is what we're after (and then maybe changeElementCount)

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


More information about the llvm-commits mailing list