Files
Mehdi Amini d18549bc5d [MLIR][Vector] Fix i32 overflow in vector mask lowering for large index bounds (#188782)
When lowering vector masks with `force-32bit-vector-indices=true`, the
mask bound (an `index`-typed value) was cast directly to `i32`. For
values
larger than INT32_MAX (e.g., 2^51), the truncating cast wraps to a small
or negative i32, turning an all-true mask into an all-false one.

Fix both the fixed-size vector path (`buildVectorComparison` in
VectorTransforms.cpp) and the scalable vector path
(`VectorCreateMaskOpConversion` in ConvertVectorToLLVM.cpp) uniformly:
clamp the bound to INT32_MAX via `arith.minsi` in index type before the
cast. For fixed-size vectors `dim` would be a tighter bound (any b >=
dim
already implies all-true), but INT32_MAX is used for consistency across
both paths.

Add a LIT regression test with a 2^51 bound and an integration test that
executes the lowered code to confirm the mask is all-true at runtime.

Fixes #113689

Assisted-by: Claude Code
2026-04-16 11:06:32 +00:00
..