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

Jakub Kuderski llvmlistbot at llvm.org
Thu Feb 26 07:10:45 PST 2026


================
@@ -1579,15 +1580,32 @@ def IndexCastTypeConstraint : TypeConstraint<Or<[
 
 def Arith_IndexCastOp
   : Arith_CastOp<"index_cast", IndexCastTypeConstraint, IndexCastTypeConstraint,
-                 [DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>]> {
+                 [DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>,
+                  DeclareOpInterfaceMethods<ArithExactFlagInterface>]> {
   let summary = "cast between index and integer types";
   let description = [{
     Casts between scalar or vector integers and corresponding 'index' scalar or
     vectors. Index is an integer of platform-specific bit width. If casting to
     a wider integer, the value is sign-extended. If casting to a narrower
     integer, the value is truncated.
+
+    If the `exact` attribute is present, it is assumed that the index type width
+    is such that the conversion does not lose information. When this assumption
----------------
kuhar wrote:

Is this the property of the intex type or the cast values fitting the representation? For example, maybe index is `i8` but values are small enough that i64 -> index doesn't lose any bits?

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


More information about the Mlir-commits mailing list