[Mlir-commits] [mlir] [mlir][arith] Add `exact` to `index_cast{, ui}` (PR #183395)

Erick Ochoa Lopez llvmlistbot at llvm.org
Fri Feb 27 06:40:28 PST 2026


================
@@ -303,14 +306,15 @@ def IndexCastOfExtSI :
 // IndexCastUIOp
 //===----------------------------------------------------------------------===//
 
-// index_castui(index_castui(x)) -> x, if dstType == srcType and at least one
-// exact flag is set (guaranteeing no information loss in either cast).
+// index_castui(index_castui(x, exact)) -> x, if dstType == srcType.
+// The inner exact guarantees the iN -> index conversion is lossless,
+// so the roundtrip through index preserves the value.
 def IndexCastUIOfIndexCastUI :
     Pat<(Arith_IndexCastUIOp:$res
           (Arith_IndexCastUIOp $x, $nneg1, $exact1), $nneg2, $exact2),
         (replaceWithValue $x),
         [(Constraint<CPred<"$0.getType() == $1.getType()">> $res, $x),
-         (Constraint<CPred<"$0 || $1">> $exact1, $exact2)]>;
+         (Constraint<CPred<"(bool)$0">> $exact1)]>;
----------------
amd-eochoalo wrote:

https://github.com/llvm/llvm-project/pull/183395/commits/b2b8392bb0d9f83ec41cceaff363b334f5e66432

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


More information about the Mlir-commits mailing list