[Mlir-commits] [mlir] [MLIR] Fix control-flow sinking through nested regions (PR #217168)

Federico Bruzzone llvmlistbot at llvm.org
Wed Aug 19 05:38:12 PDT 2026


================
@@ -80,3 +80,27 @@ func.func @test_scf_execute_region_multiblock_sink(%arg0: i32, %arg1: i32) {
   }
   return
 }
+
+// -----
+
+func.func private @sink_i32(i32)
+
+// CHECK-LABEL: @test_scf_if_sink_through_loop
+// CHECK-SAME: (%[[ARG0:.*]]: i1, %[[ARG1:.*]]: index, %[[ARG2:.*]]: i32, %[[ARG3:.*]]: i32)
+// CHECK: scf.if %[[ARG0]]
+// CHECK:   %[[V0:.*]] = arith.muli %[[ARG2]], %[[ARG3]]
+// CHECK:   scf.for
+// CHECK:     call @sink_i32(%[[V0]])
+
+func.func @test_scf_if_sink_through_loop(
----------------
FedericoBruzzone wrote:

nit: the test only covers the all-users-inside case.

Can we add a negative case where the sunk value has a second use outside the conditional?

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


More information about the Mlir-commits mailing list