[Mlir-commits] [mlir] [mlir][Interfaces] Track and infer no-overflow flags in integer ranges (PR #191777)
Mehdi Amini
llvmlistbot at llvm.org
Mon Apr 13 07:50:28 PDT 2026
================
@@ -65,8 +176,11 @@ void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
void arith::AddIOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
SetIntRangeFn setResultRange) {
- setResultRange(getResult(), inferAdd(argRanges, convertArithOverflowFlags(
- getOverflowFlags())));
+ OverflowFlags declaredFlags = convertArithOverflowFlags(getOverflowFlags());
+ ConstantIntRanges range = inferAdd(argRanges, declaredFlags);
+ OverflowFlags overflowFlags =
+ proveNoOverflowForAdd(argRanges) | declaredFlags;
----------------
joker-eph wrote:
> would it be possible that declared flags differ from the inferred one?
Of course, but why does it matter when you do an or?
Basically if the bit is 1 already, in the declared one, why would you infer it? Whether it is 1 or 0 the result is still 1.
https://github.com/llvm/llvm-project/pull/191777
More information about the Mlir-commits
mailing list