[Mlir-commits] [mlir] [MLIR][SideEffects][MemoryEffects] Modified LICM to be more aggressive when checking movability of ops with MemWrite effects (PR #155344)
Mo Bagherbeik
llvmlistbot at llvm.org
Wed Oct 8 14:24:02 PDT 2025
================
@@ -1437,3 +1437,338 @@ func.func @do_not_hoist_vector_transfer_ops_memref(
}
func.return %final : vector<4x4xf32>
}
+
+// -----
+
+// CHECK-LABEL func.func @move_single_resource_basic
+func.func @move_single_resource_basic() attributes {} {
+ %c0_i32 = arith.constant 0 : i32
+ %c1_i32 = arith.constant 10 : i32
+ %c2_i32 = arith.constant 1 : i32
+ %c0_i32_0 = arith.constant 0 : i32
+
+ // Single write effect on one resource in a triple-nested loop
+ // No loop-variant inputs to op and no read effects -> movable
+ // CHECK: "test.test_effects_write_A"() : () -> ()
+ // CHECK: scf.for
+ // CHECK: scf.for
+ // CHECK: scf.for
+
+ scf.for %arg0 = %c0_i32 to %c1_i32 step %c2_i32 : i32 {
+ scf.for %arg1 = %c0_i32 to %c1_i32 step %c2_i32 : i32 {
+ scf.for %arg2 = %c0_i32 to %c1_i32 step %c2_i32 : i32 {
+ "test.test_effects_write_A"() : () -> ()
+ }
+ }
+ }
+ return
+}
+
+// -----
+
+// CHECK-LABEL func.func @move_single_resource_write_dominant
+func.func @move_single_resource_write_dominant() attributes {} {
+ %c0_i32 = arith.constant 0 : i32
+ %c1_i32 = arith.constant 10 : i32
+ %c2_i32 = arith.constant 1 : i32
----------------
mbagherbeikTT wrote:
I made my constant naming consistent with the stored values. On that note, I was looking for a way to arbitrarily tag ops, in this case the loops, in IR to use with the checker but couldn't find anything. I ended up using different constants for the loops' upper bounds so we can check exactly which loop was moved where instead. That should make the tests easier to understand.
https://github.com/llvm/llvm-project/pull/155344
More information about the Mlir-commits
mailing list