[Mlir-commits] [mlir] [mlir][LLVM] Prevent vector bit-width overflow (PR #220898)
Matthias Springer
llvmlistbot at llvm.org
Thu Sep 10 02:54:21 PDT 2026
================
@@ -1589,9 +1589,14 @@ def LLVM_vector_insert
"type($srcvec) `into` type($res)";
let extraClassDeclaration = [{
uint64_t getVectorBitWidth(Type vector) {
- return getVectorNumElements(vector).getKnownMinValue() *
- ::llvm::cast<VectorType>(vector).getElementType()
- .getIntOrFloatBitWidth();
+ auto vectorType = ::llvm::cast<VectorType>(vector);
+ // A scalable vector dimension is its known minimum element count.
+ uint64_t minNumElements = vectorType.getDimSize(0);
+ uint64_t elementBitWidth =
+ vectorType.getElementType().getIntOrFloatBitWidth();
+ if (minNumElements > uint64_t(-1) / elementBitWidth)
----------------
matthias-springer wrote:
nit: `std::numeric_limits<uint64_t>::max()` instead of `uint64_t(-1)`?
https://github.com/llvm/llvm-project/pull/220898
More information about the Mlir-commits
mailing list