[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.
----------------
matthias-springer wrote:

Can you make this part of a docstring for the `getVectorBitWidth` function? (Same for the function below.) Also mention that this returns max `uint64_t` in case of overflow or change result type to `FailureOr`/`std::optional`.

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


More information about the Mlir-commits mailing list