[llvm] [DAG] Adding MVT::widenIntegerElementType to widen both Scalar and Vectors of integer type. (PR #207148)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 04:34:33 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;
----------------
RKSimon wrote:
Make it easier to assert where the failure occurred:
```cpp
MVT SclTy = getIntegerVT(BaseTy.getScalarSizeInBits() * 2);
assert(SclTy != MVT::INVALID_SIMPLE_VALUE_TYPE &&
"Failed to widened to a valid MVT!");
MVT ResTy = changeElementType(getIntegerVT(SclTy);
assert(ResTy != MVT::INVALID_SIMPLE_VALUE_TYPE &&
"Failed to widened to a valid MVT!");
return ResTy;
```
https://github.com/llvm/llvm-project/pull/207148
More information about the llvm-commits
mailing list