[Mlir-commits] [mlir] [MLIR][Arith] Fix index_cast/index_castui chain folding to check intermediate width (PR #189042)

Krzysztof Drewniak llvmlistbot at llvm.org
Fri Mar 27 11:50:33 PDT 2026


================
@@ -1909,6 +1909,15 @@ OpFoldResult arith::FPToSIOp::fold(FoldAdaptor adaptor) {
 // IndexCastOp
 //===----------------------------------------------------------------------===//
 
+/// Return the bit-width of \p t for the purpose of index_cast width checks.
+/// For vector types use the element type; index maps to its internal storage
+/// width (64 on all current targets).
----------------
krzysz00 wrote:

Ok, to be fair, on all practical targets, `index => i64 => index` (I think even if those are a cast and a castui) is lossless. `i64 => index => i64` requires proof. If we're willing to make temporary assumptions about what can realistically occur, `i32 => index => i32` is going to be sound.

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


More information about the Mlir-commits mailing list