[Mlir-commits] [mlir] [mlir][Interfaces] Track and infer no-overflow flags in integer ranges (PR #191777)

Mehdi Amini llvmlistbot at llvm.org
Tue Apr 14 10:30:52 PDT 2026


================
@@ -24,8 +24,16 @@ static constexpr uint64_t kMaxSubgroupSize = 128;
 
 static ConstantIntRanges getIndexRange(uint64_t umin, uint64_t umax) {
   unsigned width = IndexType::kInternalStorageBitWidth;
-  return ConstantIntRanges::fromUnsigned(APInt(width, umin),
-                                         APInt(width, umax));
+  ConstantIntRanges range =
+      ConstantIntRanges::fromUnsigned(APInt(width, umin), APInt(width, umax));
+
+  // Attach no-wrap guarantees only when the signed interpretation is also
+  // non-negative. GPU ids/dims are semantically non-negative; this check keeps
+  // us conservative for ranges whose unsigned upper bound crosses the sign bit.
+  if (range.smin().isNonNegative())
----------------
joker-eph wrote:

Why only check smin and not smax?

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


More information about the Mlir-commits mailing list