1 // RUN: mlir-opt -test-make-isolated-from-above=simple -allow-unregistered-dialect --split-input-file %s | FileCheck %s
2 // RUN: mlir-opt -test-make-isolated-from-above=clone-ops-with-no-operands -allow-unregistered-dialect --split-input-file %s | FileCheck %s --check-prefix=CLONE1
3 // RUN: mlir-opt -test-make-isolated-from-above=clone-ops-with-operands -allow-unregistered-dialect --split-input-file %s | FileCheck %s --check-prefix=CLONE2
5 func.func @make_isolated_from_above_single_block(%arg0 : index, %arg1 : index) {
6 %c0 = arith.constant 0: index
7 %c1 = arith.constant 1 : index
8 %empty = tensor.empty(%arg0, %arg1) : tensor<?x?xf32>
9 %d0 = tensor.dim %empty, %c0 : tensor<?x?xf32>
10 %d1 = tensor.dim %empty, %c1 : tensor<?x?xf32>
11 "test.one_region_with_operands_op"() ({
12 "foo.yield"(%c0, %c1, %d0, %d1) : (index, index, index, index) -> ()
16 // CHECK-LABEL: func @make_isolated_from_above_single_block(
17 // CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index
18 // CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index
19 // CHECK-DAG: %[[C0:.+]] = arith.constant 0 : index
20 // CHECK-DAG: %[[C1:.+]] = arith.constant 1 : index
21 // CHECK-DAG: %[[EMPTY:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])
22 // CHECK-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]
23 // CHECK-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]
24 // CHECK: test.isolated_one_region_op %[[C0]], %[[C1]], %[[D0]], %[[D1]]
25 // CHECK-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index, %[[B2:[a-zA-Z0-9]+]]: index, %[[B3:[a-zA-Z0-9]+]]: index)
26 // CHECK: "foo.yield"(%[[B0]], %[[B1]], %[[B2]], %[[B3]])
28 // CLONE1-LABEL: func @make_isolated_from_above_single_block(
29 // CLONE1-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index
30 // CLONE1-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index
31 // CLONE1-DAG: %[[C0:.+]] = arith.constant 0 : index
32 // CLONE1-DAG: %[[C1:.+]] = arith.constant 1 : index
33 // CLONE1-DAG: %[[EMPTY:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])
34 // CLONE1-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]
35 // CLONE1-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]
36 // CLONE1: test.isolated_one_region_op %[[D0]], %[[D1]]
37 // CLONE1-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index)
38 // CLONE1-DAG: %[[C0_0:.+]] = arith.constant 0 : index
39 // CLONE1-DAG: %[[C1_0:.+]] = arith.constant 1 : index
40 // CLONE1: "foo.yield"(%[[C0_0]], %[[C1_0]], %[[B0]], %[[B1]])
42 // CLONE2-LABEL: func @make_isolated_from_above_single_block(
43 // CLONE2-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index
44 // CLONE2-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index
45 // CLONE2: test.isolated_one_region_op %[[ARG0]], %[[ARG1]]
46 // CLONE2-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index)
47 // CLONE2-DAG: %[[C0:.+]] = arith.constant 0 : index
48 // CLONE2-DAG: %[[C1:.+]] = arith.constant 1 : index
49 // CLONE2-DAG: %[[EMPTY:.+]] = tensor.empty(%[[B0]], %[[B1]])
50 // CLONE2-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]
51 // CLONE2-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]
52 // CLONE2: "foo.yield"(%[[C0]], %[[C1]], %[[D0]], %[[D1]])
56 func.func @make_isolated_from_above_multiple_blocks(%arg0 : index, %arg1 : index, %arg2 : index) {
57 %c0 = arith.constant 0: index
58 %c1 = arith.constant 1 : index
59 %empty = tensor.empty(%arg0, %arg1) : tensor<?x?xf32>
60 %d0 = tensor.dim %empty, %c0 : tensor<?x?xf32>
61 %d1 = tensor.dim %empty, %c1 : tensor<?x?xf32>
62 "test.one_region_with_operands_op"(%arg2) ({
64 cf.br ^bb1(%b0: index)
66 "foo.yield"(%c0, %c1, %d0, %d1, %b1) : (index, index, index, index, index) -> ()
70 // CHECK-LABEL: func @make_isolated_from_above_multiple_blocks(
71 // CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index
72 // CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index
73 // CHECK-SAME: %[[ARG2:[a-zA-Z0-9]+]]: index
74 // CHECK-DAG: %[[C0:.+]] = arith.constant 0 : index
75 // CHECK-DAG: %[[C1:.+]] = arith.constant 1 : index
76 // CHECK-DAG: %[[EMPTY:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])
77 // CHECK-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]
78 // CHECK-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]
79 // CHECK: test.isolated_one_region_op %[[ARG2]], %[[C0]], %[[C1]], %[[D0]], %[[D1]]
80 // CHECK-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index, %[[B2:[a-zA-Z0-9]+]]: index, %[[B3:[a-zA-Z0-9]+]]: index, %[[B4:[a-zA-Z0-9]+]]: index)
81 // CHECK-NEXT: cf.br ^bb1
83 // CHECK: "foo.yield"(%[[B1]], %[[B2]], %[[B3]], %[[B4]], %[[B0]])
85 // CLONE1-LABEL: func @make_isolated_from_above_multiple_blocks(
86 // CLONE1-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index
87 // CLONE1-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index
88 // CLONE1-SAME: %[[ARG2:[a-zA-Z0-9]+]]: index
89 // CLONE1-DAG: %[[C0:.+]] = arith.constant 0 : index
90 // CLONE1-DAG: %[[C1:.+]] = arith.constant 1 : index
91 // CLONE1-DAG: %[[EMPTY:.+]] = tensor.empty(%[[ARG0]], %[[ARG1]])
92 // CLONE1-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]
93 // CLONE1-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]
94 // CLONE1: test.isolated_one_region_op %[[ARG2]], %[[D0]], %[[D1]]
95 // CLONE1-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index, %[[B2:[a-zA-Z0-9]+]]: index)
96 // CLONE1-DAG: %[[C0_0:.+]] = arith.constant 0 : index
97 // CLONE1-DAG: %[[C1_0:.+]] = arith.constant 1 : index
98 // CLONE1-NEXT: cf.br ^bb1
100 // CLONE1: "foo.yield"(%[[C0_0]], %[[C1_0]], %[[B1]], %[[B2]], %[[B0]])
102 // CLONE2-LABEL: func @make_isolated_from_above_multiple_blocks(
103 // CLONE2-SAME: %[[ARG0:[a-zA-Z0-9]+]]: index
104 // CLONE2-SAME: %[[ARG1:[a-zA-Z0-9]+]]: index
105 // CLONE2-SAME: %[[ARG2:[a-zA-Z0-9]+]]: index
106 // CLONE2: test.isolated_one_region_op %[[ARG2]], %[[ARG0]], %[[ARG1]]
107 // CLONE2-NEXT: ^bb0(%[[B0:[a-zA-Z0-9]+]]: index, %[[B1:[a-zA-Z0-9]+]]: index, %[[B2:[a-zA-Z0-9]+]]: index)
108 // CLONE2-DAG: %[[C0:.+]] = arith.constant 0 : index
109 // CLONE2-DAG: %[[C1:.+]] = arith.constant 1 : index
110 // CLONE2-DAG: %[[EMPTY:.+]] = tensor.empty(%[[B1]], %[[B2]])
111 // CLONE2-DAG: %[[D0:.+]] = tensor.dim %[[EMPTY]], %[[C0]]
112 // CLONE2-DAG: %[[D1:.+]] = tensor.dim %[[EMPTY]], %[[C1]]
113 // CLONE2-NEXT: cf.br ^bb1
115 // CLONE2: "foo.yield"(%[[C0]], %[[C1]], %[[D0]], %[[D1]], %[[B0]])