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

Razvan Lupusoru llvmlistbot at llvm.org
Tue Mar 3 15:00:52 PST 2026


================
@@ -288,31 +288,38 @@ def SelectI1ToNot :
 // IndexCastOp
 //===----------------------------------------------------------------------===//
 
-// index_cast(index_cast(x)) -> x, if dstType == srcType.
+// index_cast(index_cast(x, exact)) -> x, if dstType == srcType.
----------------
razvanlupusoru wrote:

> I think the long-term fix is a pattern that's dependent on DLTI attributes which looks up the target index bitwidth and uses that to determine soundness.

This indeed sounds like the proper way.

> The other solution is to go looking through various bits of code and plumbing through exactness.

Sure - and this is effectively what I was trying to do to restore the behavior I needed by ensuring that utilities I was using, namely `getValueOrCreateCastToIndexLike`, were relying on caller to determine correctness regarding "exact"ness; that said I certainly would prefer the DLTI based solution.

@amd-eochoalo Any thoughts on what approach you're considering?

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


More information about the Mlir-commits mailing list