[Mlir-commits] [mlir] [mlir][LLVM] PromotableOpInterface for PtrToIntOp and IntToPtrOp (PR #234309)

Andy Kaylor llvmlistbot at llvm.org
Wed Oct 21 14:48:31 PDT 2026


================
@@ -1226,6 +1226,55 @@ llvm.func @indirect_blocking_use_in_different_region(%arg0 : i1) {
 
 // -----
 
+// CHECK-LABEL: @dead_ptrtoint_inttoptr
+llvm.func @dead_ptrtoint_inttoptr() {
+  %0 = llvm.mlir.constant(1 : i32) : i32
+  // CHECK-NOT: llvm.alloca
+  // CHECK-NOT: llvm.ptrtoint
+  // CHECK-NOT: llvm.inttoptr
+  %1 = llvm.alloca %0 x i32 : (i32) -> !llvm.ptr
+  %2 = llvm.ptrtoint %1 : !llvm.ptr to i64
+  %3 = llvm.inttoptr %2 : i64 to !llvm.ptr
----------------
andykaylor wrote:

It's a bit embarrassing to see that I was involved in the 2019 discussion linked there but I seem to have no memory of it. Having read the discussion from https://github.com/llvm/llvm-project/issues/33896, I'm a little nervous about this change. Is it possible to add a test based on the problem case reported there? It started with an alloca and pointer arithmetic from there that ended up be folded to the `ptrtoint(inttoptr(x))` scenario. I'd like to be sure we couldn't fold our way into the same problem.

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


More information about the Mlir-commits mailing list