1 // Invoke the test control-flow sink pass to test the utilities.
2 // RUN: mlir-opt -test-control-flow-sink %s | FileCheck %s
4 // CHECK-LABEL: func @test_sink
5 func.func @test_sink() {
6 %0 = "test.sink_me"() : () -> i32
7 // CHECK-NEXT: test.sink_target
8 "test.sink_target"() ({
9 // CHECK-NEXT: %[[V0:.*]] = "test.sink_me"() {was_sunk = 0 : i32}
10 // CHECK-NEXT: "test.use"(%[[V0]])
11 "test.use"(%0) : (i32) -> ()
16 // CHECK-LABEL: func @test_sink_first_region_only
17 func.func @test_sink_first_region_only() {
18 %0 = "test.sink_me"() {first} : () -> i32
19 // CHECK-NEXT: %[[V1:.*]] = "test.sink_me"() {second}
20 %1 = "test.sink_me"() {second} : () -> i32
21 // CHECK-NEXT: test.sink_target
22 "test.sink_target"() ({
23 // CHECK-NEXT: %[[V0:.*]] = "test.sink_me"() {first, was_sunk = 0 : i32}
24 // CHECK-NEXT: "test.use"(%[[V0]])
25 "test.use"(%0) : (i32) -> ()
27 "test.use"(%1) : (i32) -> ()
32 // CHECK-LABEL: func @test_sink_targeted_op_only
33 func.func @test_sink_targeted_op_only() {
34 %0 = "test.sink_me"() : () -> i32
35 // CHECK-NEXT: %[[V1:.*]] = "test.dont_sink_me"
36 %1 = "test.dont_sink_me"() : () -> i32
37 // CHECK-NEXT: test.sink_target
38 "test.sink_target"() ({
39 // CHECK-NEXT: %[[V0:.*]] = "test.sink_me"
40 // CHECK-NEXT: "test.use"(%[[V0]], %[[V1]])
41 "test.use"(%0, %1) : (i32, i32) -> ()