[Mlir-commits] [mlir] [mlir] Fix mem2reg crash on scalable vector store/load with matching type (PR #209426)
Tobias Gysi
llvmlistbot at llvm.org
Tue Jul 14 06:08:18 PDT 2026
================
@@ -256,6 +256,12 @@ static Value createExtractAndCast(OpBuilder &builder, Location loc,
/*narrowingConversion=*/true) &&
"expected that the compatibility was checked before");
+ // Nothing has to be done if the types are already the same. This also
+ // avoids querying the bit size of types that may not have one, such as
+ // scalable vectors.
+ if (srcType == targetType)
----------------
gysit wrote:
A possible alternative would have to been to extend the `getTypeSizeInBits` calls below to check if the `TypeSize` has a fixed size. That would be more conservative and failsafe since the current code assumes we never get here with two different scalable vector types (which is probably ensured by an earlier cast compatibility check).
However, I believe your fix works for the case where all loads and stores are of the same scalable vector type and it sort of complements the implementation of `areConversionCompatible`.
https://github.com/llvm/llvm-project/pull/209426
More information about the Mlir-commits
mailing list