1 ; RUN: llvm-dis < %s.bc| FileCheck %s
2 ; RUN: verify-uselistorder < %s.bc
4 ; memOperations.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
5 ; The test checks that LLVM does not misread memory related instructions of
10 ; CHECK: %res1 = alloca i8
13 ; CHECK-NEXT: %res2 = alloca i8, i32 2
14 %res2 = alloca i8, i32 2
16 ; CHECK-NEXT: %res3 = alloca i8, i32 2, align 4
17 %res3 = alloca i8, i32 2, align 4
19 ; CHECK-NEXT: %res4 = alloca i8, align 4
20 %res4 = alloca i8, align 4
30 ; CHECK: %res1 = load i8, i8* %ptr1
31 %res1 = load i8, i8* %ptr1
33 ; CHECK-NEXT: %res2 = load volatile i8, i8* %ptr1
34 %res2 = load volatile i8, i8* %ptr1
36 ; CHECK-NEXT: %res3 = load i8, i8* %ptr1, align 1
37 %res3 = load i8, i8* %ptr1, align 1
39 ; CHECK-NEXT: %res4 = load volatile i8, i8* %ptr1, align 1
40 %res4 = load volatile i8, i8* %ptr1, align 1
42 ; CHECK-NEXT: %res5 = load i8, i8* %ptr1, !nontemporal !0
43 %res5 = load i8, i8* %ptr1, !nontemporal !0
45 ; CHECK-NEXT: %res6 = load volatile i8, i8* %ptr1, !nontemporal !0
46 %res6 = load volatile i8, i8* %ptr1, !nontemporal !0
48 ; CHECK-NEXT: %res7 = load i8, i8* %ptr1, align 1, !nontemporal !0
49 %res7 = load i8, i8* %ptr1, align 1, !nontemporal !0
51 ; CHECK-NEXT: %res8 = load volatile i8, i8* %ptr1, align 1, !nontemporal !0
52 %res8 = load volatile i8, i8* %ptr1, align 1, !nontemporal !0
54 ; CHECK-NEXT: %res9 = load i8, i8* %ptr1, !invariant.load !1
55 %res9 = load i8, i8* %ptr1, !invariant.load !1
57 ; CHECK-NEXT: %res10 = load volatile i8, i8* %ptr1, !invariant.load !1
58 %res10 = load volatile i8, i8* %ptr1, !invariant.load !1
60 ; CHECK-NEXT: %res11 = load i8, i8* %ptr1, align 1, !invariant.load !1
61 %res11 = load i8, i8* %ptr1, align 1, !invariant.load !1
63 ; CHECK-NEXT: %res12 = load volatile i8, i8* %ptr1, align 1, !invariant.load !1
64 %res12 = load volatile i8, i8* %ptr1, align 1, !invariant.load !1
66 ; CHECK-NEXT: %res13 = load i8, i8* %ptr1, {{[(!nontemporal !0, !invariant.load !1) | (!invariant.load !1, !nontemporal !0)]}}
67 %res13 = load i8, i8* %ptr1, !nontemporal !0, !invariant.load !1
69 ; CHECK-NEXT: %res14 = load volatile i8, i8* %ptr1, {{[(!nontemporal !0, !invariant.load !1) | (!invariant.load !1, !nontemporal !0)]}}
70 %res14 = load volatile i8, i8* %ptr1, !nontemporal !0, !invariant.load !1
72 ; CHECK-NEXT: %res15 = load i8, i8* %ptr1, align 1, {{[(!nontemporal !0, !invariant.load !1) | (!invariant.load !1, !nontemporal !0)]}}
73 %res15 = load i8, i8* %ptr1, align 1, !nontemporal !0, !invariant.load !1
75 ; CHECK-NEXT: %res16 = load volatile i8, i8* %ptr1, align 1, {{[(!nontemporal !0, !invariant.load !1) | (!invariant.load !1, !nontemporal !0)]}}
76 %res16 = load volatile i8, i8* %ptr1, align 1, !nontemporal !0, !invariant.load !1
81 define void @loadAtomic(){
86 ; CHECK: %res1 = load atomic i8, i8* %ptr1 unordered, align 1
87 %res1 = load atomic i8, i8* %ptr1 unordered, align 1
89 ; CHECK-NEXT: %res2 = load atomic i8, i8* %ptr1 monotonic, align 1
90 %res2 = load atomic i8, i8* %ptr1 monotonic, align 1
92 ; CHECK-NEXT: %res3 = load atomic i8, i8* %ptr1 acquire, align 1
93 %res3 = load atomic i8, i8* %ptr1 acquire, align 1
95 ; CHECK-NEXT: %res4 = load atomic i8, i8* %ptr1 seq_cst, align 1
96 %res4 = load atomic i8, i8* %ptr1 seq_cst, align 1
98 ; CHECK-NEXT: %res5 = load atomic volatile i8, i8* %ptr1 unordered, align 1
99 %res5 = load atomic volatile i8, i8* %ptr1 unordered, align 1
101 ; CHECK-NEXT: %res6 = load atomic volatile i8, i8* %ptr1 monotonic, align 1
102 %res6 = load atomic volatile i8, i8* %ptr1 monotonic, align 1
104 ; CHECK-NEXT: %res7 = load atomic volatile i8, i8* %ptr1 acquire, align 1
105 %res7 = load atomic volatile i8, i8* %ptr1 acquire, align 1
107 ; CHECK-NEXT: %res8 = load atomic volatile i8, i8* %ptr1 seq_cst, align 1
108 %res8 = load atomic volatile i8, i8* %ptr1 seq_cst, align 1
110 ; CHECK-NEXT: %res9 = load atomic i8, i8* %ptr1 syncscope("singlethread") unordered, align 1
111 %res9 = load atomic i8, i8* %ptr1 syncscope("singlethread") unordered, align 1
113 ; CHECK-NEXT: %res10 = load atomic i8, i8* %ptr1 syncscope("singlethread") monotonic, align 1
114 %res10 = load atomic i8, i8* %ptr1 syncscope("singlethread") monotonic, align 1
116 ; CHECK-NEXT: %res11 = load atomic i8, i8* %ptr1 syncscope("singlethread") acquire, align 1
117 %res11 = load atomic i8, i8* %ptr1 syncscope("singlethread") acquire, align 1
119 ; CHECK-NEXT: %res12 = load atomic i8, i8* %ptr1 syncscope("singlethread") seq_cst, align 1
120 %res12 = load atomic i8, i8* %ptr1 syncscope("singlethread") seq_cst, align 1
122 ; CHECK-NEXT: %res13 = load atomic volatile i8, i8* %ptr1 syncscope("singlethread") unordered, align 1
123 %res13 = load atomic volatile i8, i8* %ptr1 syncscope("singlethread") unordered, align 1
125 ; CHECK-NEXT: %res14 = load atomic volatile i8, i8* %ptr1 syncscope("singlethread") monotonic, align 1
126 %res14 = load atomic volatile i8, i8* %ptr1 syncscope("singlethread") monotonic, align 1
128 ; CHECK-NEXT: %res15 = load atomic volatile i8, i8* %ptr1 syncscope("singlethread") acquire, align 1
129 %res15 = load atomic volatile i8, i8* %ptr1 syncscope("singlethread") acquire, align 1
131 ; CHECK-NEXT: %res16 = load atomic volatile i8, i8* %ptr1 syncscope("singlethread") seq_cst, align 1
132 %res16 = load atomic volatile i8, i8* %ptr1 syncscope("singlethread") seq_cst, align 1
137 define void @store(){
141 ; CHECK: store i8 2, i8* %ptr1
142 store i8 2, i8* %ptr1
144 ; CHECK-NEXT: store volatile i8 2, i8* %ptr1
145 store volatile i8 2, i8* %ptr1
147 ; CHECK-NEXT: store i8 2, i8* %ptr1, align 1
148 store i8 2, i8* %ptr1, align 1
150 ; CHECK-NEXT: store volatile i8 2, i8* %ptr1, align 1
151 store volatile i8 2, i8* %ptr1, align 1
153 ; CHECK-NEXT: store i8 2, i8* %ptr1, !nontemporal !0
154 store i8 2, i8* %ptr1, !nontemporal !0
156 ; CHECK-NEXT: store volatile i8 2, i8* %ptr1, !nontemporal !0
157 store volatile i8 2, i8* %ptr1, !nontemporal !0
159 ; CHECK-NEXT: store i8 2, i8* %ptr1, align 1, !nontemporal !0
160 store i8 2, i8* %ptr1, align 1, !nontemporal !0
162 ; CHECK-NEXT: store volatile i8 2, i8* %ptr1, align 1, !nontemporal !0
163 store volatile i8 2, i8* %ptr1, align 1, !nontemporal !0
168 define void @storeAtomic(){
172 ; CHECK: store atomic i8 2, i8* %ptr1 unordered, align 1
173 store atomic i8 2, i8* %ptr1 unordered, align 1
175 ; CHECK-NEXT: store atomic i8 2, i8* %ptr1 monotonic, align 1
176 store atomic i8 2, i8* %ptr1 monotonic, align 1
178 ; CHECK-NEXT: store atomic i8 2, i8* %ptr1 release, align 1
179 store atomic i8 2, i8* %ptr1 release, align 1
181 ; CHECK-NEXT: store atomic i8 2, i8* %ptr1 seq_cst, align 1
182 store atomic i8 2, i8* %ptr1 seq_cst, align 1
184 ; CHECK-NEXT: store atomic volatile i8 2, i8* %ptr1 unordered, align 1
185 store atomic volatile i8 2, i8* %ptr1 unordered, align 1
187 ; CHECK-NEXT: store atomic volatile i8 2, i8* %ptr1 monotonic, align 1
188 store atomic volatile i8 2, i8* %ptr1 monotonic, align 1
190 ; CHECK-NEXT: store atomic volatile i8 2, i8* %ptr1 release, align 1
191 store atomic volatile i8 2, i8* %ptr1 release, align 1
193 ; CHECK-NEXT: store atomic volatile i8 2, i8* %ptr1 seq_cst, align 1
194 store atomic volatile i8 2, i8* %ptr1 seq_cst, align 1
196 ; CHECK-NEXT: store atomic i8 2, i8* %ptr1 syncscope("singlethread") unordered, align 1
197 store atomic i8 2, i8* %ptr1 syncscope("singlethread") unordered, align 1
199 ; CHECK-NEXT: store atomic i8 2, i8* %ptr1 syncscope("singlethread") monotonic, align 1
200 store atomic i8 2, i8* %ptr1 syncscope("singlethread") monotonic, align 1
202 ; CHECK-NEXT: store atomic i8 2, i8* %ptr1 syncscope("singlethread") release, align 1
203 store atomic i8 2, i8* %ptr1 syncscope("singlethread") release, align 1
205 ; CHECK-NEXT: store atomic i8 2, i8* %ptr1 syncscope("singlethread") seq_cst, align 1
206 store atomic i8 2, i8* %ptr1 syncscope("singlethread") seq_cst, align 1
208 ; CHECK-NEXT: store atomic volatile i8 2, i8* %ptr1 syncscope("singlethread") unordered, align 1
209 store atomic volatile i8 2, i8* %ptr1 syncscope("singlethread") unordered, align 1
211 ; CHECK-NEXT: store atomic volatile i8 2, i8* %ptr1 syncscope("singlethread") monotonic, align 1
212 store atomic volatile i8 2, i8* %ptr1 syncscope("singlethread") monotonic, align 1
214 ; CHECK-NEXT: store atomic volatile i8 2, i8* %ptr1 syncscope("singlethread") release, align 1
215 store atomic volatile i8 2, i8* %ptr1 syncscope("singlethread") release, align 1
217 ; CHECK-NEXT: store atomic volatile i8 2, i8* %ptr1 syncscope("singlethread") seq_cst, align 1
218 store atomic volatile i8 2, i8* %ptr1 syncscope("singlethread") seq_cst, align 1
223 define void @cmpxchg(i32* %ptr,i32 %cmp,i32 %new){
225 ;cmpxchg [volatile] <ty>* <pointer>, <ty> <cmp>, <ty> <new> [singlethread] <ordering>
227 ; CHECK: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new monotonic monotonic
228 ; CHECK-NEXT: %res1 = extractvalue { i32, i1 } [[TMP]], 0
229 %res1 = cmpxchg i32* %ptr, i32 %cmp, i32 %new monotonic monotonic
231 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new monotonic monotonic
232 ; CHECK-NEXT: %res2 = extractvalue { i32, i1 } [[TMP]], 0
233 %res2 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new monotonic monotonic
235 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") monotonic monotonic
236 ; CHECK-NEXT: %res3 = extractvalue { i32, i1 } [[TMP]], 0
237 %res3 = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") monotonic monotonic
239 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") monotonic monotonic
240 ; CHECK-NEXT: %res4 = extractvalue { i32, i1 } [[TMP]], 0
241 %res4 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") monotonic monotonic
244 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new acquire acquire
245 ; CHECK-NEXT: %res5 = extractvalue { i32, i1 } [[TMP]], 0
246 %res5 = cmpxchg i32* %ptr, i32 %cmp, i32 %new acquire acquire
248 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new acquire acquire
249 ; CHECK-NEXT: %res6 = extractvalue { i32, i1 } [[TMP]], 0
250 %res6 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new acquire acquire
252 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") acquire acquire
253 ; CHECK-NEXT: %res7 = extractvalue { i32, i1 } [[TMP]], 0
254 %res7 = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") acquire acquire
256 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") acquire acquire
257 ; CHECK-NEXT: %res8 = extractvalue { i32, i1 } [[TMP]], 0
258 %res8 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") acquire acquire
261 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new release monotonic
262 ; CHECK-NEXT: %res9 = extractvalue { i32, i1 } [[TMP]], 0
263 %res9 = cmpxchg i32* %ptr, i32 %cmp, i32 %new release monotonic
265 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new release monotonic
266 ; CHECK-NEXT: %res10 = extractvalue { i32, i1 } [[TMP]], 0
267 %res10 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new release monotonic
269 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") release monotonic
270 ; CHECK-NEXT: %res11 = extractvalue { i32, i1 } [[TMP]], 0
271 %res11 = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") release monotonic
273 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") release monotonic
274 ; CHECK-NEXT: %res12 = extractvalue { i32, i1 } [[TMP]], 0
275 %res12 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") release monotonic
278 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new acq_rel acquire
279 ; CHECK-NEXT: %res13 = extractvalue { i32, i1 } [[TMP]], 0
280 %res13 = cmpxchg i32* %ptr, i32 %cmp, i32 %new acq_rel acquire
282 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new acq_rel acquire
283 ; CHECK-NEXT: %res14 = extractvalue { i32, i1 } [[TMP]], 0
284 %res14 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new acq_rel acquire
286 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") acq_rel acquire
287 ; CHECK-NEXT: %res15 = extractvalue { i32, i1 } [[TMP]], 0
288 %res15 = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") acq_rel acquire
290 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") acq_rel acquire
291 ; CHECK-NEXT: %res16 = extractvalue { i32, i1 } [[TMP]], 0
292 %res16 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") acq_rel acquire
295 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new seq_cst seq_cst
296 ; CHECK-NEXT: %res17 = extractvalue { i32, i1 } [[TMP]], 0
297 %res17 = cmpxchg i32* %ptr, i32 %cmp, i32 %new seq_cst seq_cst
299 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new seq_cst seq_cst
300 ; CHECK-NEXT: %res18 = extractvalue { i32, i1 } [[TMP]], 0
301 %res18 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new seq_cst seq_cst
303 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") seq_cst seq_cst
304 ; CHECK-NEXT: %res19 = extractvalue { i32, i1 } [[TMP]], 0
305 %res19 = cmpxchg i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") seq_cst seq_cst
307 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") seq_cst seq_cst
308 ; CHECK-NEXT: %res20 = extractvalue { i32, i1 } [[TMP]], 0
309 %res20 = cmpxchg volatile i32* %ptr, i32 %cmp, i32 %new syncscope("singlethread") seq_cst seq_cst
314 define void @getelementptr({i8, i8}, {i8, i8}* %s, <4 x i8*> %ptrs, <4 x i64> %offsets ){
316 ; CHECK: %res1 = getelementptr { i8, i8 }, { i8, i8 }* %s, i32 1, i32 1
317 %res1 = getelementptr {i8, i8}, {i8, i8}* %s, i32 1, i32 1
319 ; CHECK-NEXT: %res2 = getelementptr inbounds { i8, i8 }, { i8, i8 }* %s, i32 1, i32 1
320 %res2 = getelementptr inbounds {i8, i8}, {i8, i8}* %s, i32 1, i32 1
322 ; CHECK-NEXT: %res3 = getelementptr i8, <4 x i8*> %ptrs, <4 x i64> %offsets
323 %res3 = getelementptr i8, <4 x i8*> %ptrs, <4 x i64> %offsets
328 !0 = metadata !{ i32 1 }