[Mlir-commits] [mlir] [MLIR] Guard against overflow when simplifying affine expressions. (PR #228010)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Oct 9 02:43:43 PDT 2026


lipracer wrote:

  Non-blocking.

  The two spots guarded here (visitMulExpr / visitAddExpr) are what the repro hits, but for the record there are several other arithmetic steps in this same flattener that can overflow the same way and aren't
  covered. For example, the ceildiv path in visitDivExpr:
```
  // lhs ceildiv c  <=>  (lhs + c - 1) floordiv c
  SmallVector<int64_t, 8> dividend(lhs);
  dividend.back() += divisor - 1;   // overflows if the constant term is already near INT64_MAX
  addLocalFloorDivId(dividend, divisor, divExpr);
```

  This is theoretical overflow — fuzzer-reachable, but it doesn't happen in real workloads. A fundamental fix would be dynamic/arbitrary precision, but that hurts performance; otherwise a sufficiently large fixed
  width, which is essentially the current approach. So I'm neutral here, just flagging that the coverage is partial.

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


More information about the Mlir-commits mailing list