[Mlir-commits] [mlir] [mlir][LLVM] Prevent vector bit-width overflow (PR #220898)
Mehdi Amini
llvmlistbot at llvm.org
Mon Sep 7 04:31:43 PDT 2026
================
@@ -1589,9 +1589,13 @@ 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);
+ uint64_t numElements = vectorType.getDimSize(0);
----------------
joker-eph wrote:
Yes, it should be fine: for a scalable vector, `getDimSize(0)` is the known minimum element count; scalability is tracked separately. So this implementation preserves the previous `getKnownMinValue()` semantics, while avoiding the narrowing through `ElementCount`. I clarified that in the code (and added a test with scalable vec)
https://github.com/llvm/llvm-project/pull/220898
More information about the Mlir-commits
mailing list