[all-commits] [llvm/llvm-project] d18549: [MLIR][Vector] Fix i32 overflow in vector mask low...

Mehdi Amini via All-commits all-commits at lists.llvm.org
Thu Apr 16 04:06:54 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d18549bc5d39f82a25458836216d1fc7bdb0369d
      https://github.com/llvm/llvm-project/commit/d18549bc5d39f82a25458836216d1fc7bdb0369d
  Author: Mehdi Amini <joker.eph at gmail.com>
  Date:   2026-04-16 (Thu, 16 Apr 2026)

  Changed paths:
    M mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
    M mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
    M mlir/test/Conversion/VectorToLLVM/vector-mask-to-llvm.mlir
    M mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir
    M mlir/test/Conversion/VectorToLLVM/vector-xfer-to-llvm.mlir
    M mlir/test/Integration/Dialect/Vector/CPU/create-mask.mlir

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list