207
|
1 // RUN: mlir-opt %s -pass-pipeline='func(test-alias-analysis)' -split-input-file -allow-unregistered-dialect 2>&1 | FileCheck %s
|
|
2
|
|
3 // CHECK-LABEL: Testing : "simple"
|
|
4 // CHECK-DAG: func.region0#0 <-> func.region0#1: MayAlias
|
|
5
|
|
6 // CHECK-DAG: alloca_1#0 <-> alloca_2#0: NoAlias
|
|
7 // CHECK-DAG: alloca_1#0 <-> alloc_1#0: NoAlias
|
|
8 // CHECK-DAG: alloca_1#0 <-> alloc_2#0: NoAlias
|
|
9 // CHECK-DAG: alloca_1#0 <-> func.region0#0: NoAlias
|
|
10 // CHECK-DAG: alloca_1#0 <-> func.region0#1: NoAlias
|
|
11
|
|
12 // CHECK-DAG: alloca_2#0 <-> alloc_1#0: NoAlias
|
|
13 // CHECK-DAG: alloca_2#0 <-> alloc_2#0: NoAlias
|
|
14 // CHECK-DAG: alloca_2#0 <-> func.region0#0: NoAlias
|
|
15 // CHECK-DAG: alloca_2#0 <-> func.region0#1: NoAlias
|
|
16
|
|
17 // CHECK-DAG: alloc_1#0 <-> alloc_2#0: NoAlias
|
|
18 // CHECK-DAG: alloc_1#0 <-> func.region0#0: NoAlias
|
|
19 // CHECK-DAG: alloc_1#0 <-> func.region0#1: NoAlias
|
|
20
|
|
21 // CHECK-DAG: alloc_2#0 <-> func.region0#0: NoAlias
|
|
22 // CHECK-DAG: alloc_2#0 <-> func.region0#1: NoAlias
|
|
23 func @simple(%arg: memref<2xf32>, %arg1: memref<2xf32>) attributes {test.ptr = "func"} {
|
|
24 %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32>
|
|
25 %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32>
|
|
26 %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32>
|
|
27 %3 = memref.alloc() {test.ptr = "alloc_2"} : memref<8x64xf32>
|
|
28 return
|
|
29 }
|
|
30
|
|
31 // -----
|
|
32
|
|
33 // CHECK-LABEL: Testing : "control_flow"
|
|
34 // CHECK-DAG: alloca_1#0 <-> func.region0.block1#0: MustAlias
|
|
35 // CHECK-DAG: alloca_1#0 <-> func.region0.block2#0: MustAlias
|
|
36
|
|
37 // CHECK-DAG: alloca_2#0 <-> func.region0.block1#0: NoAlias
|
|
38 // CHECK-DAG: alloca_2#0 <-> func.region0.block2#0: NoAlias
|
|
39
|
|
40 // CHECK-DAG: alloc_1#0 <-> func.region0.block1#0: NoAlias
|
|
41 // CHECK-DAG: alloc_1#0 <-> func.region0.block2#0: NoAlias
|
|
42
|
|
43 // CHECK-DAG: func.region0#0 <-> func.region0.block1#0: NoAlias
|
|
44 // CHECK-DAG: func.region0#0 <-> func.region0.block2#0: NoAlias
|
|
45
|
|
46 // CHECK-DAG: func.region0#1 <-> func.region0.block1#0: NoAlias
|
|
47 // CHECK-DAG: func.region0#1 <-> func.region0.block2#0: NoAlias
|
|
48
|
|
49 // CHECK-DAG: func.region0.block1#0 <-> func.region0.block2#0: MustAlias
|
|
50 func @control_flow(%arg: memref<2xf32>, %cond: i1) attributes {test.ptr = "func"} {
|
|
51 %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32>
|
|
52 %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32>
|
|
53 %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32>
|
|
54
|
|
55 cond_br %cond, ^bb1(%0 : memref<8x64xf32>), ^bb2(%0 : memref<8x64xf32>)
|
|
56
|
|
57 ^bb1(%arg1: memref<8x64xf32>):
|
|
58 br ^bb2(%arg1 : memref<8x64xf32>)
|
|
59
|
|
60 ^bb2(%arg2: memref<8x64xf32>):
|
|
61 return
|
|
62 }
|
|
63
|
|
64 // -----
|
|
65
|
|
66 // CHECK-LABEL: Testing : "control_flow_merge"
|
|
67 // CHECK-DAG: alloca_1#0 <-> func.region0.block1#0: MustAlias
|
|
68 // CHECK-DAG: alloca_1#0 <-> func.region0.block2#0: MayAlias
|
|
69
|
|
70 // CHECK-DAG: alloca_2#0 <-> func.region0.block1#0: NoAlias
|
|
71 // CHECK-DAG: alloca_2#0 <-> func.region0.block2#0: NoAlias
|
|
72
|
|
73 // CHECK-DAG: alloc_1#0 <-> func.region0.block1#0: NoAlias
|
|
74 // CHECK-DAG: alloc_1#0 <-> func.region0.block2#0: MayAlias
|
|
75
|
|
76 // CHECK-DAG: func.region0#0 <-> func.region0.block1#0: NoAlias
|
|
77 // CHECK-DAG: func.region0#0 <-> func.region0.block2#0: NoAlias
|
|
78
|
|
79 // CHECK-DAG: func.region0#1 <-> func.region0.block1#0: NoAlias
|
|
80 // CHECK-DAG: func.region0#1 <-> func.region0.block2#0: NoAlias
|
|
81
|
|
82 // CHECK-DAG: func.region0.block1#0 <-> func.region0.block2#0: MayAlias
|
|
83 func @control_flow_merge(%arg: memref<2xf32>, %cond: i1) attributes {test.ptr = "func"} {
|
|
84 %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32>
|
|
85 %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32>
|
|
86 %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32>
|
|
87
|
|
88 cond_br %cond, ^bb1(%0 : memref<8x64xf32>), ^bb2(%2 : memref<8x64xf32>)
|
|
89
|
|
90 ^bb1(%arg1: memref<8x64xf32>):
|
|
91 br ^bb2(%arg1 : memref<8x64xf32>)
|
|
92
|
|
93 ^bb2(%arg2: memref<8x64xf32>):
|
|
94 return
|
|
95 }
|
|
96
|
|
97 // -----
|
|
98
|
|
99 // CHECK-LABEL: Testing : "region_control_flow"
|
|
100 // CHECK-DAG: alloca_1#0 <-> if_alloca#0: MustAlias
|
|
101 // CHECK-DAG: alloca_1#0 <-> if_alloca_merge#0: MayAlias
|
|
102 // CHECK-DAG: alloca_1#0 <-> if_alloc#0: NoAlias
|
|
103
|
|
104 // CHECK-DAG: alloca_2#0 <-> if_alloca#0: NoAlias
|
|
105 // CHECK-DAG: alloca_2#0 <-> if_alloca_merge#0: MayAlias
|
|
106 // CHECK-DAG: alloca_2#0 <-> if_alloc#0: NoAlias
|
|
107
|
|
108 // CHECK-DAG: alloc_1#0 <-> if_alloca#0: NoAlias
|
|
109 // CHECK-DAG: alloc_1#0 <-> if_alloca_merge#0: NoAlias
|
|
110 // CHECK-DAG: alloc_1#0 <-> if_alloc#0: MustAlias
|
|
111
|
|
112 // CHECK-DAG: if_alloca#0 <-> if_alloca_merge#0: MayAlias
|
|
113 // CHECK-DAG: if_alloca#0 <-> if_alloc#0: NoAlias
|
|
114 // CHECK-DAG: if_alloca#0 <-> func.region0#0: NoAlias
|
|
115 // CHECK-DAG: if_alloca#0 <-> func.region0#1: NoAlias
|
|
116
|
|
117 // CHECK-DAG: if_alloca_merge#0 <-> if_alloc#0: NoAlias
|
|
118 // CHECK-DAG: if_alloca_merge#0 <-> func.region0#0: NoAlias
|
|
119 // CHECK-DAG: if_alloca_merge#0 <-> func.region0#1: NoAlias
|
|
120
|
|
121 // CHECK-DAG: if_alloc#0 <-> func.region0#0: NoAlias
|
|
122 // CHECK-DAG: if_alloc#0 <-> func.region0#1: NoAlias
|
|
123 func @region_control_flow(%arg: memref<2xf32>, %cond: i1) attributes {test.ptr = "func"} {
|
|
124 %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32>
|
|
125 %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32>
|
|
126 %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32>
|
|
127
|
|
128 %3 = scf.if %cond -> (memref<8x64xf32>) {
|
|
129 scf.yield %0 : memref<8x64xf32>
|
|
130 } else {
|
|
131 scf.yield %0 : memref<8x64xf32>
|
|
132 } {test.ptr = "if_alloca"}
|
|
133
|
|
134 %4 = scf.if %cond -> (memref<8x64xf32>) {
|
|
135 scf.yield %0 : memref<8x64xf32>
|
|
136 } else {
|
|
137 scf.yield %1 : memref<8x64xf32>
|
|
138 } {test.ptr = "if_alloca_merge"}
|
|
139
|
|
140 %5 = scf.if %cond -> (memref<8x64xf32>) {
|
|
141 scf.yield %2 : memref<8x64xf32>
|
|
142 } else {
|
|
143 scf.yield %2 : memref<8x64xf32>
|
|
144 } {test.ptr = "if_alloc"}
|
|
145 return
|
|
146 }
|
|
147
|
|
148 // -----
|
|
149
|
|
150 // CHECK-LABEL: Testing : "region_loop_control_flow"
|
|
151 // CHECK-DAG: alloca_1#0 <-> for_alloca#0: MustAlias
|
|
152 // CHECK-DAG: alloca_1#0 <-> for_alloca.region0#0: MayAlias
|
|
153 // CHECK-DAG: alloca_1#0 <-> for_alloca.region0#1: MustAlias
|
|
154
|
|
155 // CHECK-DAG: alloca_2#0 <-> for_alloca#0: NoAlias
|
|
156 // CHECK-DAG: alloca_2#0 <-> for_alloca.region0#0: MayAlias
|
|
157 // CHECK-DAG: alloca_2#0 <-> for_alloca.region0#1: NoAlias
|
|
158
|
|
159 // CHECK-DAG: alloc_1#0 <-> for_alloca#0: NoAlias
|
|
160 // CHECK-DAG: alloc_1#0 <-> for_alloca.region0#0: MayAlias
|
|
161 // CHECK-DAG: alloc_1#0 <-> for_alloca.region0#1: NoAlias
|
|
162
|
|
163 // CHECK-DAG: for_alloca#0 <-> for_alloca.region0#0: MayAlias
|
|
164 // CHECK-DAG: for_alloca#0 <-> for_alloca.region0#1: MustAlias
|
|
165 // CHECK-DAG: for_alloca#0 <-> func.region0#0: NoAlias
|
|
166 // CHECK-DAG: for_alloca#0 <-> func.region0#1: NoAlias
|
|
167 // CHECK-DAG: for_alloca#0 <-> func.region0#2: NoAlias
|
|
168 // CHECK-DAG: for_alloca#0 <-> func.region0#3: NoAlias
|
|
169
|
|
170 // CHECK-DAG: for_alloca.region0#0 <-> for_alloca.region0#1: MayAlias
|
|
171 // CHECK-DAG: for_alloca.region0#0 <-> func.region0#0: MayAlias
|
|
172 // CHECK-DAG: for_alloca.region0#0 <-> func.region0#1: MayAlias
|
|
173 // CHECK-DAG: for_alloca.region0#0 <-> func.region0#2: MayAlias
|
|
174 // CHECK-DAG: for_alloca.region0#0 <-> func.region0#3: MayAlias
|
|
175
|
|
176 // CHECK-DAG: for_alloca.region0#1 <-> func.region0#0: NoAlias
|
|
177 // CHECK-DAG: for_alloca.region0#1 <-> func.region0#1: NoAlias
|
|
178 // CHECK-DAG: for_alloca.region0#1 <-> func.region0#2: NoAlias
|
|
179 // CHECK-DAG: for_alloca.region0#1 <-> func.region0#3: NoAlias
|
|
180 func @region_loop_control_flow(%arg: memref<2xf32>, %loopI0 : index,
|
|
181 %loopI1 : index, %loopI2 : index) attributes {test.ptr = "func"} {
|
|
182 %0 = memref.alloca() {test.ptr = "alloca_1"} : memref<8x64xf32>
|
|
183 %1 = memref.alloca() {test.ptr = "alloca_2"} : memref<8x64xf32>
|
|
184 %2 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32>
|
|
185
|
|
186 %result = scf.for %i0 = %loopI0 to %loopI1 step %loopI2 iter_args(%si = %0) -> (memref<8x64xf32>) {
|
|
187 scf.yield %si : memref<8x64xf32>
|
|
188 } {test.ptr = "for_alloca"}
|
|
189 return
|
|
190 }
|
|
191
|
|
192 // -----
|
|
193
|
|
194 // CHECK-LABEL: Testing : "view_like"
|
|
195 // CHECK-DAG: alloc_1#0 <-> view#0: NoAlias
|
|
196
|
|
197 // CHECK-DAG: alloca_1#0 <-> view#0: MustAlias
|
|
198
|
|
199 // CHECK-DAG: view#0 <-> func.region0#0: NoAlias
|
|
200 // CHECK-DAG: view#0 <-> func.region0#1: NoAlias
|
|
201 func @view_like(%arg: memref<2xf32>, %size: index) attributes {test.ptr = "func"} {
|
|
202 %1 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32>
|
|
203
|
|
204 %c0 = constant 0 : index
|
|
205 %2 = memref.alloca (%size) {test.ptr = "alloca_1"} : memref<?xi8>
|
|
206 %3 = memref.view %2[%c0][] {test.ptr = "view"} : memref<?xi8> to memref<8x64xf32>
|
|
207 return
|
|
208 }
|
|
209
|
|
210 // -----
|
|
211
|
|
212 // CHECK-LABEL: Testing : "constants"
|
|
213 // CHECK-DAG: alloc_1#0 <-> constant_1#0: NoAlias
|
|
214 // CHECK-DAG: alloc_1#0 <-> constant_2#0: NoAlias
|
|
215 // CHECK-DAG: alloc_1#0 <-> constant_3#0: NoAlias
|
|
216
|
|
217 // CHECK-DAG: constant_1#0 <-> constant_2#0: MayAlias
|
|
218 // CHECK-DAG: constant_1#0 <-> constant_3#0: MayAlias
|
|
219 // CHECK-DAG: constant_1#0 <-> func.region0#0: MayAlias
|
|
220
|
|
221 // CHECK-DAG: constant_2#0 <-> constant_3#0: MayAlias
|
|
222 // CHECK-DAG: constant_2#0 <-> func.region0#0: MayAlias
|
|
223
|
|
224 // CHECK-DAG: constant_3#0 <-> func.region0#0: MayAlias
|
|
225 func @constants(%arg: memref<2xf32>) attributes {test.ptr = "func"} {
|
|
226 %1 = memref.alloc() {test.ptr = "alloc_1"} : memref<8x64xf32>
|
|
227
|
|
228 %c0 = constant {test.ptr = "constant_1"} 0 : index
|
|
229 %c0_2 = constant {test.ptr = "constant_2"} 0 : index
|
|
230 %c1 = constant {test.ptr = "constant_3"} 1 : index
|
|
231
|
|
232 return
|
|
233 }
|