[llvm] [DAG] Adding MVT::widenIntegerElementType to widen both Scalar and Vectors of integer type. (PR #207148)

Chirag Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 06:36:46 PDT 2026


================
@@ -272,6 +272,20 @@ namespace llvm {
       return MVT::getVectorVT(EltVT, EltCnt * 2);
     }
 
+    // Return a VT for an Integer or vetor of integer type doubled in size
+    MVT widenIntegerElementType() const {
+      MVT BaseTy = getScalarType();
+      assert(BaseTy.isInteger() && "Not an integer or vector of integer MVT!");
+      assert((BaseTy != MVT::LAST_INTEGER_VALUETYPE) &&
+             "Widening of this Integer type not supported !");
+
+      MVT ResTy =
+          changeElementType(getIntegerVT(BaseTy.getScalarSizeInBits() * 2));
+      assert(ResTy != MVT::INVALID_SIMPLE_VALUE_TYPE &&
+             "Failed to widened to a valid MVT!");
+      return ResTy;
----------------
ChiragPatel8 wrote:

Is assert check after scalar widening required? At the beginning, we check if it's integer AND if it's not the last type of integer (i.e. i512) for which doubling won't be possible. For all other cases, doubling will be guaranteed, no ?

The assert check for vectors after change element is I believe needed because the implementation in change element might change in future. Currently, the wrong vector of integer type will assert way before in change element function. 

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


More information about the llvm-commits mailing list