1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
2f4a2713aSLionel Sambuc
3f4a2713aSLionel Sambuc // CHECK: @i = global [[INT:i[0-9]+]] 0
4f4a2713aSLionel Sambuc volatile int i, j, k;
5f4a2713aSLionel Sambuc volatile int ar[5];
6f4a2713aSLionel Sambuc volatile char c;
7f4a2713aSLionel Sambuc // CHECK: @ci = global [[CINT:.*]] zeroinitializer
8f4a2713aSLionel Sambuc volatile _Complex int ci;
9f4a2713aSLionel Sambuc volatile struct S {
10f4a2713aSLionel Sambuc #ifdef __cplusplus
11f4a2713aSLionel Sambuc void operator =(volatile struct S&o) volatile;
12f4a2713aSLionel Sambuc #endif
13f4a2713aSLionel Sambuc int i;
14f4a2713aSLionel Sambuc } a, b;
15f4a2713aSLionel Sambuc
16f4a2713aSLionel Sambuc //void operator =(volatile struct S&o1, volatile struct S&o2) volatile;
17f4a2713aSLionel Sambuc int printf(const char *, ...);
18f4a2713aSLionel Sambuc
19f4a2713aSLionel Sambuc
20f4a2713aSLionel Sambuc // CHECK: define void @{{.*}}test
test()21f4a2713aSLionel Sambuc void test() {
22f4a2713aSLionel Sambuc
23f4a2713aSLionel Sambuc asm("nop"); // CHECK: call void asm
24f4a2713aSLionel Sambuc
25f4a2713aSLionel Sambuc // should not load
26f4a2713aSLionel Sambuc i;
27f4a2713aSLionel Sambuc
28f4a2713aSLionel Sambuc (float)(ci);
29f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
30f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
31f4a2713aSLionel Sambuc // CHECK-NEXT: sitofp [[INT]]
32f4a2713aSLionel Sambuc
33f4a2713aSLionel Sambuc // These are not uses in C++:
34f4a2713aSLionel Sambuc // [expr.static.cast]p6:
35f4a2713aSLionel Sambuc // The lvalue-to-rvalue . . . conversions are not applied to the expression.
36f4a2713aSLionel Sambuc (void)ci;
37f4a2713aSLionel Sambuc (void)a;
38f4a2713aSLionel Sambuc
39f4a2713aSLionel Sambuc (void)(ci=ci);
40f4a2713aSLionel Sambuc // CHECK-NEXT: [[R:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
41f4a2713aSLionel Sambuc // CHECK-NEXT: [[I:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
42f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
43f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
44f4a2713aSLionel Sambuc
45f4a2713aSLionel Sambuc (void)(i=j);
46f4a2713aSLionel Sambuc // CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* @j
47f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* @i
48f4a2713aSLionel Sambuc
49f4a2713aSLionel Sambuc ci+=ci;
50f4a2713aSLionel Sambuc // CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
51f4a2713aSLionel Sambuc // CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
52f4a2713aSLionel Sambuc // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
53f4a2713aSLionel Sambuc // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
54f4a2713aSLionel Sambuc // Not sure why they're ordered this way.
55f4a2713aSLionel Sambuc // CHECK-NEXT: [[R:%.*]] = add [[INT]] [[R2]], [[R1]]
56f4a2713aSLionel Sambuc // CHECK-NEXT: [[I:%.*]] = add [[INT]] [[I2]], [[I1]]
57f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
58f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
59f4a2713aSLionel Sambuc
60f4a2713aSLionel Sambuc // Note that C++ requires an extra load volatile over C from the LHS of the '+'.
61f4a2713aSLionel Sambuc (ci += ci) + ci;
62f4a2713aSLionel Sambuc // CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
63f4a2713aSLionel Sambuc // CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
64f4a2713aSLionel Sambuc // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
65f4a2713aSLionel Sambuc // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
66f4a2713aSLionel Sambuc // CHECK-NEXT: [[R:%.*]] = add [[INT]] [[R2]], [[R1]]
67f4a2713aSLionel Sambuc // CHECK-NEXT: [[I:%.*]] = add [[INT]] [[I2]], [[I1]]
68f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
69f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
70f4a2713aSLionel Sambuc // CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
71f4a2713aSLionel Sambuc // CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
72f4a2713aSLionel Sambuc // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
73f4a2713aSLionel Sambuc // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
74f4a2713aSLionel Sambuc // These additions can be elided.
75f4a2713aSLionel Sambuc // CHECK-NEXT: add [[INT]] [[R1]], [[R2]]
76f4a2713aSLionel Sambuc // CHECK-NEXT: add [[INT]] [[I1]], [[I2]]
77f4a2713aSLionel Sambuc
78f4a2713aSLionel Sambuc asm("nop"); // CHECK-NEXT: call void asm
79f4a2713aSLionel Sambuc
80f4a2713aSLionel Sambuc // Extra load volatile in C++.
81f4a2713aSLionel Sambuc (i += j) + k;
82f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
83f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
84f4a2713aSLionel Sambuc // CHECK-NEXT: add nsw [[INT]]
85f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
86f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
87f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
88f4a2713aSLionel Sambuc // CHECK-NEXT: add nsw [[INT]]
89f4a2713aSLionel Sambuc
90f4a2713aSLionel Sambuc asm("nop"); // CHECK-NEXT: call void asm
91f4a2713aSLionel Sambuc
92f4a2713aSLionel Sambuc // Extra load volatile in C++.
93f4a2713aSLionel Sambuc (i += j) + 1;
94f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
95f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
96f4a2713aSLionel Sambuc // CHECK-NEXT: add nsw [[INT]]
97f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
98f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
99f4a2713aSLionel Sambuc // CHECK-NEXT: add nsw [[INT]]
100f4a2713aSLionel Sambuc
101f4a2713aSLionel Sambuc asm("nop"); // CHECK-NEXT: call void asm
102f4a2713aSLionel Sambuc
103f4a2713aSLionel Sambuc ci+ci;
104f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
105f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
106f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
107f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
108f4a2713aSLionel Sambuc // CHECK-NEXT: add [[INT]]
109f4a2713aSLionel Sambuc // CHECK-NEXT: add [[INT]]
110f4a2713aSLionel Sambuc
111f4a2713aSLionel Sambuc __real i;
112f4a2713aSLionel Sambuc
113f4a2713aSLionel Sambuc +ci;
114f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
115f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
116f4a2713aSLionel Sambuc
117f4a2713aSLionel Sambuc asm("nop"); // CHECK-NEXT: call void asm
118f4a2713aSLionel Sambuc
119f4a2713aSLionel Sambuc (void)(i=i);
120f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
121f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
122f4a2713aSLionel Sambuc
123f4a2713aSLionel Sambuc (float)(i=i);
124f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
125f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
126f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
127f4a2713aSLionel Sambuc // CHECK-NEXT: sitofp
128f4a2713aSLionel Sambuc
129f4a2713aSLionel Sambuc (void)i;
130f4a2713aSLionel Sambuc
131f4a2713aSLionel Sambuc i=i;
132f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
133f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
134f4a2713aSLionel Sambuc
135f4a2713aSLionel Sambuc // Extra load volatile in C++.
136f4a2713aSLionel Sambuc i=i=i;
137f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
138f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
139f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
140f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
141f4a2713aSLionel Sambuc
142f4a2713aSLionel Sambuc (void)__builtin_choose_expr(0, i=i, j=j);
143f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
144f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
145f4a2713aSLionel Sambuc
146f4a2713aSLionel Sambuc k ? (i=i) : (j=j);
147f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
148f4a2713aSLionel Sambuc // CHECK-NEXT: icmp
149f4a2713aSLionel Sambuc // CHECK-NEXT: br i1
150f4a2713aSLionel Sambuc // CHECK: load volatile
151f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
152f4a2713aSLionel Sambuc // CHECK-NEXT: br label
153f4a2713aSLionel Sambuc // CHECK: load volatile
154f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
155f4a2713aSLionel Sambuc // CHECK-NEXT: br label
156f4a2713aSLionel Sambuc // CHECK: phi
157f4a2713aSLionel Sambuc
158f4a2713aSLionel Sambuc (void)(i,(i=i));
159f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
160f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
161f4a2713aSLionel Sambuc
162f4a2713aSLionel Sambuc i=i,k;
163f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* @i
164f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
165f4a2713aSLionel Sambuc
166f4a2713aSLionel Sambuc (i=j,k=j);
167f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* @j
168f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
169f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* @j
170f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @k
171f4a2713aSLionel Sambuc
172f4a2713aSLionel Sambuc (i=j,k);
173f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* @j
174f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
175f4a2713aSLionel Sambuc
176f4a2713aSLionel Sambuc (i,j);
177f4a2713aSLionel Sambuc
178f4a2713aSLionel Sambuc // Extra load in C++.
179f4a2713aSLionel Sambuc i=c=k;
180f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
181f4a2713aSLionel Sambuc // CHECK-NEXT: trunc
182f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
183f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
184f4a2713aSLionel Sambuc // CHECK-NEXT: sext
185f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
186f4a2713aSLionel Sambuc
187f4a2713aSLionel Sambuc i+=k;
188f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
189f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
190f4a2713aSLionel Sambuc // CHECK-NEXT: add nsw [[INT]]
191f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
192f4a2713aSLionel Sambuc
193f4a2713aSLionel Sambuc ci;
194f4a2713aSLionel Sambuc
195f4a2713aSLionel Sambuc asm("nop"); // CHECK-NEXT: call void asm
196f4a2713aSLionel Sambuc
197f4a2713aSLionel Sambuc (int)ci;
198f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile {{.*}} @ci, i32 0, i32 0
199f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile {{.*}} @ci, i32 0, i32 1
200f4a2713aSLionel Sambuc
201f4a2713aSLionel Sambuc (bool)ci;
202f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile {{.*}} @ci, i32 0, i32 0
203f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile {{.*}} @ci, i32 0, i32 1
204f4a2713aSLionel Sambuc // CHECK-NEXT: icmp ne
205f4a2713aSLionel Sambuc // CHECK-NEXT: icmp ne
206f4a2713aSLionel Sambuc // CHECK-NEXT: or i1
207f4a2713aSLionel Sambuc
208f4a2713aSLionel Sambuc ci=ci;
209f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
210f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
211f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
212f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
213f4a2713aSLionel Sambuc
214f4a2713aSLionel Sambuc asm("nop"); // CHECK-NEXT: call void asm
215f4a2713aSLionel Sambuc
216f4a2713aSLionel Sambuc // Extra load in C++.
217f4a2713aSLionel Sambuc ci=ci=ci;
218f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
219f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
220f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
221f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
222f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
223f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
224f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
225f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
226f4a2713aSLionel Sambuc
227f4a2713aSLionel Sambuc __imag ci = __imag ci = __imag ci;
228f4a2713aSLionel Sambuc // CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
229f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
230f4a2713aSLionel Sambuc // CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
231f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
232f4a2713aSLionel Sambuc
233f4a2713aSLionel Sambuc __real (i = j);
234f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
235f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
236f4a2713aSLionel Sambuc
237f4a2713aSLionel Sambuc __imag i;
238f4a2713aSLionel Sambuc
239f4a2713aSLionel Sambuc // ============================================================
240f4a2713aSLionel Sambuc // FIXME: Test cases we get wrong.
241f4a2713aSLionel Sambuc
242f4a2713aSLionel Sambuc // A use. We load all of a into a copy of a, then load i. gcc forgets to do
243f4a2713aSLionel Sambuc // the assignment.
244f4a2713aSLionel Sambuc // (a = a).i;
245f4a2713aSLionel Sambuc
246f4a2713aSLionel Sambuc // ============================================================
247f4a2713aSLionel Sambuc // Test cases where we intentionally differ from gcc, due to suspected bugs in
248f4a2713aSLionel Sambuc // gcc.
249f4a2713aSLionel Sambuc
250f4a2713aSLionel Sambuc // Not a use. gcc forgets to do the assignment.
251*0a6a1f1dSLionel Sambuc // CHECK-NEXT: call {{.*}}void
252f4a2713aSLionel Sambuc ((a=a),a);
253f4a2713aSLionel Sambuc
254f4a2713aSLionel Sambuc // Not a use. gcc gets this wrong, it doesn't emit the copy!
255*0a6a1f1dSLionel Sambuc // CHECK-NEXT: call {{.*}}void
256f4a2713aSLionel Sambuc (void)(a=a);
257f4a2713aSLionel Sambuc
258f4a2713aSLionel Sambuc // Not a use. gcc got this wrong in 4.2 and omitted the side effects
259f4a2713aSLionel Sambuc // entirely, but it is fixed in 4.4.0.
260f4a2713aSLionel Sambuc __imag (i = j);
261f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
262f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
263f4a2713aSLionel Sambuc
264f4a2713aSLionel Sambuc // C++ does an extra load here. Note that we have to do full loads.
265f4a2713aSLionel Sambuc (float)(ci=ci);
266f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
267f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
268f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
269f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
270f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
271f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
272f4a2713aSLionel Sambuc // CHECK-NEXT: sitofp
273f4a2713aSLionel Sambuc
274f4a2713aSLionel Sambuc // Not a use, bug? gcc treats this as not a use, that's probably a
275f4a2713aSLionel Sambuc // bug due to tree folding ignoring volatile.
276f4a2713aSLionel Sambuc (int)(ci=ci);
277f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
278f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
279f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
280f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
281f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
282f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
283f4a2713aSLionel Sambuc
284f4a2713aSLionel Sambuc // A use.
285f4a2713aSLionel Sambuc (float)(i=i);
286f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
287f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
288f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
289f4a2713aSLionel Sambuc // CHECK-NEXT: sitofp
290f4a2713aSLionel Sambuc
291f4a2713aSLionel Sambuc // A use. gcc treats this as not a use, that's probably a bug due to tree
292f4a2713aSLionel Sambuc // folding ignoring volatile.
293f4a2713aSLionel Sambuc (int)(i=i);
294f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
295f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
296f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
297f4a2713aSLionel Sambuc
298f4a2713aSLionel Sambuc // A use.
299f4a2713aSLionel Sambuc -(i=j);
300f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
301f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
302f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
303f4a2713aSLionel Sambuc // CHECK-NEXT: sub
304f4a2713aSLionel Sambuc
305f4a2713aSLionel Sambuc // A use. gcc treats this a not a use, that's probably a bug due to tree
306f4a2713aSLionel Sambuc // folding ignoring volatile.
307f4a2713aSLionel Sambuc +(i=k);
308f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
309f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
310f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
311f4a2713aSLionel Sambuc
312f4a2713aSLionel Sambuc // A use. gcc treats this a not a use, that's probably a bug due to tree
313f4a2713aSLionel Sambuc // folding ignoring volatile.
314f4a2713aSLionel Sambuc __real (ci=ci);
315f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
316f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
317f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
318f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
319f4a2713aSLionel Sambuc
320f4a2713aSLionel Sambuc // A use.
321f4a2713aSLionel Sambuc i + 0;
322f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
323f4a2713aSLionel Sambuc // CHECK-NEXT: add
324f4a2713aSLionel Sambuc
325f4a2713aSLionel Sambuc // A use.
326f4a2713aSLionel Sambuc (i=j) + i;
327f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
328f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
329f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
330f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
331f4a2713aSLionel Sambuc // CHECK-NEXT: add
332f4a2713aSLionel Sambuc
333f4a2713aSLionel Sambuc // A use. gcc treats this as not a use, that's probably a bug due to tree
334f4a2713aSLionel Sambuc // folding ignoring volatile.
335f4a2713aSLionel Sambuc (i=j) + 0;
336f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
337f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile
338f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile
339f4a2713aSLionel Sambuc // CHECK-NEXT: add
340f4a2713aSLionel Sambuc
341f4a2713aSLionel Sambuc (i,j)=k;
342f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* @k
343f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @j
344f4a2713aSLionel Sambuc
345f4a2713aSLionel Sambuc (j=k,i)=i;
346f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* @i
347f4a2713aSLionel Sambuc // CHECK-NEXT: load volatile [[INT]]* @k
348f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @j
349f4a2713aSLionel Sambuc // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
350f4a2713aSLionel Sambuc
351f4a2713aSLionel Sambuc // CHECK-NEXT: ret void
352f4a2713aSLionel Sambuc }
353