llvm.org GIT mirror llvm / d0675bd
[MemorySSA] Add new tests for invariant.groups Summary: Next round of extra tests for MSSA. I have a prototype invariant.group handling implementation that fixes all the FIXMEs, and I think it will be easier to see what is the difference if I firstly post this, and then only fix fixits. Reviewers: george.burgess.iv, dberlin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29022 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292797 91177308-0d34-0410-b5e6-96231b3b80d8 Piotr Padlewski 2 years ago
1 changed file(s) with 182 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
9797 ret i32 %add
9898 }
9999
100 define i32 @loop(i1 %a) {
101 entry:
102 %0 = alloca i32, align 4
103 ; CHECK: 1 = MemoryDef(liveOnEntry)
104 ; CHECK-NEXT: store i32 4
105 store i32 4, i32* %0, !invariant.group !0
106 ; CHECK: 2 = MemoryDef(1)
107 ; CHECK-NEXT: call void @clobber
108 call void @clobber(i32* %0)
109 br i1 %a, label %Loop.Body, label %Loop.End
110
111 Loop.Body:
112 ; FIXME: MemoryUse(1)
113 ; CHECK: MemoryUse(2)
114 ; CHECK-NEXT: %1 = load i32
115 %1 = load i32, i32* %0, !invariant.group !0
116 br i1 %a, label %Loop.End, label %Loop.Body
117
118 Loop.End:
119 ; FIXME: MemoryUse(1)
120 ; CHECK: MemoryUse(2)
121 ; CHECK-NEXT: %2 = load
122 %2 = load i32, i32* %0, align 4, !invariant.group !0
123 br i1 %a, label %Ret, label %Loop.Body
124
125 Ret:
126 ret i32 %2
127 }
128
129 define i8 @loop2(i8* %p) {
130 entry:
131 ; CHECK: 1 = MemoryDef(liveOnEntry)
132 ; CHECK-NEXT: store i8
133 store i8 4, i8* %p, !invariant.group !0
134 ; CHECK: 2 = MemoryDef(1)
135 ; CHECK-NEXT: call void @clobber
136 call void @clobber8(i8* %p)
137 %after = call i8* @llvm.invariant.group.barrier(i8* %p)
138 br i1 undef, label %Loop.Body, label %Loop.End
139
140 Loop.Body:
141 ; 4 = MemoryPhi({entry,2},{Loop.Body,3},{Loop.End,5})
142 ; CHECK: MemoryUse(4)
143 ; CHECK-NEXT: %0 = load i8
144 %0 = load i8, i8* %after, !invariant.group !0
145
146 ; FIXME: MemoryUse(1)
147 ; CHECK: MemoryUse(4)
148 ; CHECK-NEXT: %1 = load i8
149 %1 = load i8, i8* %p, !invariant.group !0
150
151 ; CHECK: 3 = MemoryDef(4)
152 store i8 4, i8* %after, !invariant.group !0
153
154 br i1 undef, label %Loop.End, label %Loop.Body
155
156 Loop.End:
157 ; 5 = MemoryPhi({entry,2},{Loop.Body,3})
158 ; CHECK: MemoryUse(5)
159 ; CHECK-NEXT: %2 = load
160 %2 = load i8, i8* %after, align 4, !invariant.group !0
161
162 ; FIXME: MemoryUse(1)
163 ; CHECK: MemoryUse(5)
164 ; CHECK-NEXT: %3 = load
165 %3 = load i8, i8* %p, align 4, !invariant.group !0
166 br i1 undef, label %Ret, label %Loop.Body
167
168 Ret:
169 ret i8 %3
170 }
171
172
173 define i8 @loop3(i8* %p) {
174 entry:
175 ; CHECK: 1 = MemoryDef(liveOnEntry)
176 ; CHECK-NEXT: store i8
177 store i8 4, i8* %p, !invariant.group !0
178 ; CHECK: 2 = MemoryDef(1)
179 ; CHECK-NEXT: call void @clobber
180 call void @clobber8(i8* %p)
181 %after = call i8* @llvm.invariant.group.barrier(i8* %p)
182 br i1 undef, label %Loop.Body, label %Loop.End
183
184 Loop.Body:
185 ; CHECK: 6 = MemoryPhi({entry,2},{Loop.Body,3},{Loop.next,4},{Loop.End,5})
186 ; CHECK: MemoryUse(6)
187 ; CHECK-NEXT: %0 = load i8
188 %0 = load i8, i8* %after, !invariant.group !0
189
190 ; CHECK: 3 = MemoryDef(6)
191 ; CHECK-NEXT: call void @clobber8
192 call void @clobber8(i8* %after)
193
194 ; FIXME: MemoryUse(6)
195 ; CHECK: MemoryUse(3)
196 ; CHECK-NEXT: %1 = load i8
197 %1 = load i8, i8* %after, !invariant.group !0
198
199 br i1 undef, label %Loop.next, label %Loop.Body
200 Loop.next:
201 ; CHECK: 4 = MemoryDef(3)
202 ; CHECK-NEXT: call void @clobber8
203 call void @clobber8(i8* %after)
204
205 ; FIXME: MemoryUse(6)
206 ; CHECK: MemoryUse(4)
207 ; CHECK-NEXT: %2 = load i8
208 %2 = load i8, i8* %after, !invariant.group !0
209
210 br i1 undef, label %Loop.End, label %Loop.Body
211
212 Loop.End:
213 ; CHECK: 7 = MemoryPhi({entry,2},{Loop.next,4})
214 ; CHECK: MemoryUse(7)
215 ; CHECK-NEXT: %3 = load
216 %3 = load i8, i8* %after, align 4, !invariant.group !0
217
218 ; CHECK: 5 = MemoryDef(7)
219 ; CHECK-NEXT: call void @clobber8
220 call void @clobber8(i8* %after)
221
222 ; FIXME: MemoryUse(7)
223 ; CHECK: MemoryUse(5)
224 ; CHECK-NEXT: %4 = load
225 %4 = load i8, i8* %after, align 4, !invariant.group !0
226 br i1 undef, label %Ret, label %Loop.Body
227
228 Ret:
229 ret i8 %3
230 }
231
232 define i8 @loop4(i8* %p) {
233 entry:
234 ; CHECK: 1 = MemoryDef(liveOnEntry)
235 ; CHECK-NEXT: store i8
236 store i8 4, i8* %p, !invariant.group !0
237 ; CHECK: 2 = MemoryDef(1)
238 ; CHECK-NEXT: call void @clobber
239 call void @clobber8(i8* %p)
240 %after = call i8* @llvm.invariant.group.barrier(i8* %p)
241 br i1 undef, label %Loop.Pre, label %Loop.End
242
243 Loop.Pre:
244 ; CHECK: MemoryUse(2)
245 ; CHECK-NEXT: %0 = load i8
246 %0 = load i8, i8* %after, !invariant.group !0
247 br label %Loop.Body
248 Loop.Body:
249 ; CHECK: 4 = MemoryPhi({Loop.Pre,2},{Loop.Body,3},{Loop.End,5})
250 ; CHECK-NEXT: MemoryUse(4)
251 ; CHECK-NEXT: %1 = load i8
252 %1 = load i8, i8* %after, !invariant.group !0
253
254 ; FIXME: MemoryUse(2)
255 ; CHECK: MemoryUse(4)
256 ; CHECK-NEXT: %2 = load i8
257 %2 = load i8, i8* %p, !invariant.group !0
258
259 ; CHECK: 3 = MemoryDef(4)
260 store i8 4, i8* %after, !invariant.group !0
261 br i1 undef, label %Loop.End, label %Loop.Body
262
263 Loop.End:
264 ; CHECK: 5 = MemoryPhi({entry,2},{Loop.Body,3})
265 ; CHECK-NEXT: MemoryUse(5)
266 ; CHECK-NEXT: %3 = load
267 %3 = load i8, i8* %after, align 4, !invariant.group !0
268
269 ; FIXME: MemoryUse(2)
270 ; CHECK: MemoryUse(5)
271 ; CHECK-NEXT: %4 = load
272 %4 = load i8, i8* %p, align 4, !invariant.group !0
273 br i1 undef, label %Ret, label %Loop.Body
274
275 Ret:
276 ret i8 %3
277 }
278
100279 declare i8* @llvm.invariant.group.barrier(i8*)
280 declare void @clobber(i32*)
281 declare void @clobber8(i8*)
282
101283
102284 !0 = !{!"group1"}