[Mlir-commits] [mlir] Improving MinUI and MaxUI implementation in valuebounds (PR #207701)
Hagai Lev Hacohen
llvmlistbot at llvm.org
Mon Jul 6 06:06:16 PDT 2026
================
@@ -354,20 +354,25 @@ struct MinUIOpInterface
assert(value == minOp.getResult() && "invalid value");
// ValueBoundsConstraintSet models values as signed integers (e.g. an i8
- // 0xff is treated as -1, not 255).So, we can only derive bounds for minui
- // if both operands are provably non-negative.
+ // 0xff is treated as -1, not 255). For an unsigned minimum it is enough
+ // that a single operand is provably non-negative: minui(x, y) is in
+ // [0, y] whenever y >= 0 (and symmetrically for x).
bool lhsNonNegative =
ValueBoundsConstraintSet::isProvablyNonNegative(minOp.getLhs(), cstr);
bool rhsNonNegative =
ValueBoundsConstraintSet::isProvablyNonNegative(minOp.getRhs(), cstr);
- if (!lhsNonNegative || !rhsNonNegative)
+ if (!lhsNonNegative && !rhsNonNegative)
return;
cstr.bound(value) >= 0;
----------------
HagaiLevHacohen wrote:
What you wrote is correct, and it's exactly how I thought about it.
I added this comment.
https://github.com/llvm/llvm-project/pull/207701
More information about the Mlir-commits
mailing list