1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
4 // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=LAMBDA %s
5 // RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=BLOCKS %s
6 // expected-no-diagnostics
7 // REQUIRES: x86-registered-target
8 #ifndef HEADER
9 #define HEADER
10
11 volatile double g, g_orig;
12 volatile double &g1 = g_orig;
13
14 template <class T>
15 struct S {
16 T f;
SS17 S(T a) : f(a + g) {}
SS18 S() : f(g) {}
operator TS19 operator T() { return T(); }
operator &S20 S &operator&(const S &) { return *this; }
~SS21 ~S() {}
22 };
23
24 // CHECK-DAG: [[S_FLOAT_TY:%.+]] = type { float }
25 // CHECK-DAG: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }
26 // CHECK-DAG: [[ATOMIC_REDUCE_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 18, i32 0, i32 0, i8*
27 // CHECK-DAG: [[IMPLICIT_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 66, i32 0, i32 0, i8*
28 // CHECK-DAG: [[REDUCTION_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 18, i32 0, i32 0, i8*
29 // CHECK-DAG: [[REDUCTION_LOCK:@.+]] = common global [8 x i32] zeroinitializer
30
31 template <typename T>
tmain()32 T tmain() {
33 T t;
34 S<T> test;
35 T t_var = T(), t_var1;
36 T vec[] = {1, 2};
37 S<T> s_arr[] = {1, 2};
38 S<T> &var = test;
39 S<T> var1;
40 #pragma omp parallel
41 #pragma omp for reduction(+:t_var) reduction(&:var) reduction(&& : var1) reduction(min: t_var1) nowait
42 for (int i = 0; i < 2; ++i) {
43 vec[i] = t_var;
44 s_arr[i] = var;
45 }
46 #pragma omp parallel
47 #pragma omp for reduction(&& : t_var)
48 for (int i = 0; i < 2; ++i) {
49 vec[i] = t_var;
50 s_arr[i] = var;
51 }
52 return T();
53 }
54
main()55 int main() {
56 #ifdef LAMBDA
57 // LAMBDA: [[G:@.+]] = global double
58 // LAMBDA-LABEL: @main
59 // LAMBDA: call void [[OUTER_LAMBDA:@.+]](
60 [&]() {
61 // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
62 // LAMBDA: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
63 #pragma omp parallel
64 #pragma omp for reduction(+:g, g1)
65 for (int i = 0; i < 2; ++i) {
66 // LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}})
67 // LAMBDA: [[G_PRIVATE_ADDR:%.+]] = alloca double,
68
69 // Reduction list for runtime.
70 // LAMBDA: [[RED_LIST:%.+]] = alloca [2 x i8*],
71
72 // LAMBDA: store double 0.0{{.+}}, double* [[G_PRIVATE_ADDR]]
73 // LAMBDA: call void @__kmpc_for_static_init_4(
74 g = 1;
75 g1 = 1;
76 // LAMBDA: store double 1.0{{.+}}, double* [[G_PRIVATE_ADDR]],
77 // LAMBDA: [[G_PRIVATE_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
78 // LAMBDA: store double* [[G_PRIVATE_ADDR]], double** [[G_PRIVATE_ADDR_REF]]
79 // LAMBDA: call void [[INNER_LAMBDA:@.+]](%{{.+}}* [[ARG]])
80 // LAMBDA: call void @__kmpc_for_static_fini(
81
82 // LAMBDA: [[G_PRIV_REF:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[RED_LIST]], i64 0, i64 0
83 // LAMBDA: [[BITCAST:%.+]] = bitcast double* [[G_PRIVATE_ADDR]] to i8*
84 // LAMBDA: store i8* [[BITCAST]], i8** [[G_PRIV_REF]],
85 // LAMBDA: call i32 @__kmpc_reduce(
86 // LAMBDA: switch i32 %{{.+}}, label %[[REDUCTION_DONE:.+]] [
87 // LAMBDA: i32 1, label %[[CASE1:.+]]
88 // LAMBDA: i32 2, label %[[CASE2:.+]]
89 // LAMBDA: [[CASE1]]
90 // LAMBDA: [[G_VAL:%.+]] = load double, double* [[G]]
91 // LAMBDA: [[G_PRIV_VAL:%.+]] = load double, double* [[G_PRIVATE_ADDR]]
92 // LAMBDA: [[ADD:%.+]] = fadd double [[G_VAL]], [[G_PRIV_VAL]]
93 // LAMBDA: store double [[ADD]], double* [[G]]
94 // LAMBDA: call void @__kmpc_end_reduce(
95 // LAMBDA: br label %[[REDUCTION_DONE]]
96 // LAMBDA: [[CASE2]]
97 // LAMBDA: [[G_PRIV_VAL:%.+]] = load double, double* [[G_PRIVATE_ADDR]]
98 // LAMBDA: fadd double
99 // LAMBDA: cmpxchg i64*
100 // LAMBDA: call void @__kmpc_end_reduce(
101 // LAMBDA: br label %[[REDUCTION_DONE]]
102 // LAMBDA: [[REDUCTION_DONE]]
103 // LAMBDA: ret void
104 [&]() {
105 // LAMBDA: define {{.+}} void [[INNER_LAMBDA]](%{{.+}}* [[ARG_PTR:%.+]])
106 // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
107 g = 2;
108 g1 = 2;
109 // LAMBDA: [[ARG_PTR:%.+]] = load %{{.+}}*, %{{.+}}** [[ARG_PTR_REF]]
110 // LAMBDA: [[G_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
111 // LAMBDA: [[G_REF:%.+]] = load double*, double** [[G_PTR_REF]]
112 // LAMBDA: store double 2.0{{.+}}, double* [[G_REF]]
113 }();
114 }
115 }();
116 return 0;
117 #elif defined(BLOCKS)
118 // BLOCKS: [[G:@.+]] = global double
119 // BLOCKS-LABEL: @main
120 // BLOCKS: call void {{%.+}}(i8
121 ^{
122 // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
123 // BLOCKS: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
124 #pragma omp parallel
125 #pragma omp for reduction(-:g, g1)
126 for (int i = 0; i < 2; ++i) {
127 // BLOCKS: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}})
128 // BLOCKS: [[G_PRIVATE_ADDR:%.+]] = alloca double,
129
130 // Reduction list for runtime.
131 // BLOCKS: [[RED_LIST:%.+]] = alloca [2 x i8*],
132
133 // BLOCKS: store double 0.0{{.+}}, double* [[G_PRIVATE_ADDR]]
134 g = 1;
135 g1 = 1;
136 // BLOCKS: call void @__kmpc_for_static_init_4(
137 // BLOCKS: store double 1.0{{.+}}, double* [[G_PRIVATE_ADDR]],
138 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
139 // BLOCKS: double* [[G_PRIVATE_ADDR]]
140 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
141 // BLOCKS: call void {{%.+}}(i8
142 // BLOCKS: call void @__kmpc_for_static_fini(
143
144 // BLOCKS: [[G_PRIV_REF:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[RED_LIST]], i64 0, i64 0
145 // BLOCKS: [[BITCAST:%.+]] = bitcast double* [[G_PRIVATE_ADDR]] to i8*
146 // BLOCKS: store i8* [[BITCAST]], i8** [[G_PRIV_REF]],
147 // BLOCKS: call i32 @__kmpc_reduce(
148 // BLOCKS: switch i32 %{{.+}}, label %[[REDUCTION_DONE:.+]] [
149 // BLOCKS: i32 1, label %[[CASE1:.+]]
150 // BLOCKS: i32 2, label %[[CASE2:.+]]
151 // BLOCKS: [[CASE1]]
152 // BLOCKS: [[G_VAL:%.+]] = load double, double* [[G]]
153 // BLOCKS: [[G_PRIV_VAL:%.+]] = load double, double* [[G_PRIVATE_ADDR]]
154 // BLOCKS: [[ADD:%.+]] = fadd double [[G_VAL]], [[G_PRIV_VAL]]
155 // BLOCKS: store double [[ADD]], double* [[G]]
156 // BLOCKS: call void @__kmpc_end_reduce(
157 // BLOCKS: br label %[[REDUCTION_DONE]]
158 // BLOCKS: [[CASE2]]
159 // BLOCKS: [[G_PRIV_VAL:%.+]] = load double, double* [[G_PRIVATE_ADDR]]
160 // BLOCKS: fadd double
161 // BLOCKS: cmpxchg i64*
162 // BLOCKS: call void @__kmpc_end_reduce(
163 // BLOCKS: br label %[[REDUCTION_DONE]]
164 // BLOCKS: [[REDUCTION_DONE]]
165 // BLOCKS: ret void
166 ^{
167 // BLOCKS: define {{.+}} void {{@.+}}(i8*
168 g = 2;
169 g1 = 2;
170 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
171 // BLOCKS: store double 2.0{{.+}}, double*
172 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
173 // BLOCKS: ret
174 }();
175 }
176 }();
177 return 0;
178 #else
179 S<float> test;
180 float t_var = 0, t_var1;
181 int vec[] = {1, 2};
182 S<float> s_arr[] = {1, 2};
183 S<float> &var = test;
184 S<float> var1, arrs[10][4];
185 #pragma omp parallel
186 #pragma omp for reduction(+:t_var) reduction(&:var) reduction(&& : var1) reduction(min: t_var1)
187 for (int i = 0; i < 2; ++i) {
188 vec[i] = t_var;
189 s_arr[i] = var;
190 }
191 int arr[10][vec[1]];
192 #pragma omp parallel for reduction(+:arr[1][:vec[1]]) reduction(&:arrs[1:vec[1]][1:2])
193 for (int i = 0; i < 10; ++i)
194 ++arr[1][i];
195 return tmain<int>();
196 #endif
197 }
198
199 // CHECK: define {{.*}}i{{[0-9]+}} @main()
200 // CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]],
201 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]])
202 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 6, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, float*, [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]*, float*, [2 x i32]*, [2 x [[S_FLOAT_TY]]]*)* [[MAIN_MICROTASK:@.+]] to void
203 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, i64, i64, i32*, [2 x i32]*, [10 x [4 x [[S_FLOAT_TY]]]]*)* [[MAIN_MICROTASK1:@.+]] to void
204 // CHECK: = call {{.*}}i{{.+}} [[TMAIN_INT:@.+]]()
205 // CHECK: call {{.*}} [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
206 // CHECK: ret
207 //
208 // CHECK: define internal void [[MAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, float* dereferenceable(4) %{{.+}}, [[S_FLOAT_TY]]* dereferenceable(4) %{{.+}}, [[S_FLOAT_TY]]* dereferenceable(4) %{{.+}}, float* dereferenceable(4) %{{.+}}, [2 x i32]* dereferenceable(8) %vec, [2 x [[S_FLOAT_TY]]]* dereferenceable(8) %{{.+}})
209 // CHECK: [[T_VAR_PRIV:%.+]] = alloca float,
210 // CHECK: [[VAR_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
211 // CHECK: [[VAR1_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
212 // CHECK: [[T_VAR1_PRIV:%.+]] = alloca float,
213
214 // Reduction list for runtime.
215 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
216
217 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
218
219 // CHECK: [[T_VAR_REF:%.+]] = load float*, float** %
220 // CHECK: [[VAR1_REF:%.+]] = load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
221 // CHECK: [[T_VAR1_REF:%.+]] = load float*, float** %
222
223 // For + reduction operation initial value of private variable is 0.
224 // CHECK: store float 0.0{{.+}}, float* [[T_VAR_PRIV]],
225
226 // For & reduction operation initial value of private variable is ones in all bits.
227 // CHECK: [[VAR_REF:%.+]] = load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
228 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
229
230 // For && reduction operation initial value of private variable is 1.0.
231 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[VAR1_PRIV]])
232
233 // For min reduction operation initial value of private variable is largest repesentable value.
234 // CHECK: store float 0x47EFFFFFE0000000, float* [[T_VAR1_PRIV]],
235
236
237 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
238 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
239 // CHECK: call void @__kmpc_for_static_init_4(
240 // Skip checks for internal operations.
241 // CHECK: call void @__kmpc_for_static_fini(
242
243 // void *RedList[<n>] = {<ReductionVars>[0], ..., <ReductionVars>[<n>-1]};
244
245 // CHECK: [[T_VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 0
246 // CHECK: [[BITCAST:%.+]] = bitcast float* [[T_VAR_PRIV]] to i8*
247 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR_PRIV_REF]],
248 // CHECK: [[VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 1
249 // CHECK: [[BITCAST:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR_PRIV]] to i8*
250 // CHECK: store i8* [[BITCAST]], i8** [[VAR_PRIV_REF]],
251 // CHECK: [[VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 2
252 // CHECK: [[BITCAST:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR1_PRIV]] to i8*
253 // CHECK: store i8* [[BITCAST]], i8** [[VAR1_PRIV_REF]],
254 // CHECK: [[T_VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 3
255 // CHECK: [[BITCAST:%.+]] = bitcast float* [[T_VAR1_PRIV]] to i8*
256 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR1_PRIV_REF]],
257
258 // res = __kmpc_reduce(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>);
259
260 // CHECK: [[BITCAST:%.+]] = bitcast [4 x i8*]* [[RED_LIST]] to i8*
261 // CHECK: [[RES:%.+]] = call i32 @__kmpc_reduce(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], i32 4, i64 32, i8* [[BITCAST]], void (i8*, i8*)* [[REDUCTION_FUNC:@.+]], [8 x i32]* [[REDUCTION_LOCK]])
262
263 // switch(res)
264 // CHECK: switch i32 [[RES]], label %[[RED_DONE:.+]] [
265 // CHECK: i32 1, label %[[CASE1:.+]]
266 // CHECK: i32 2, label %[[CASE2:.+]]
267 // CHECK: ]
268
269 // case 1:
270 // t_var += t_var_reduction;
271 // CHECK: [[T_VAR_VAL:%.+]] = load float, float* [[T_VAR_REF]],
272 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load float, float* [[T_VAR_PRIV]],
273 // CHECK: [[UP:%.+]] = fadd float [[T_VAR_VAL]], [[T_VAR_PRIV_VAL]]
274 // CHECK: store float [[UP]], float* [[T_VAR_REF]],
275
276 // var = var.operator &(var_reduction);
277 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @{{.+}}([[S_FLOAT_TY]]* [[VAR_REF]], [[S_FLOAT_TY]]* dereferenceable(4) [[VAR_PRIV]])
278 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR_REF]] to i8*
279 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[UP]] to i8*
280 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
281
282 // var1 = var1.operator &&(var1_reduction);
283 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_REF]])
284 // CHECK: [[VAR1_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
285 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
286 // CHECK: [[TRUE]]
287 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_PRIV]])
288 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
289 // CHECK: br label %[[END2]]
290 // CHECK: [[END2]]
291 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
292 // CHECK: [[CONV:%.+]] = uitofp i1 [[COND_LVALUE]] to float
293 // CHECK: call void @{{.+}}([[S_FLOAT_TY]]* [[COND_LVALUE:%.+]], float [[CONV]])
294 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR1_REF]] to i8*
295 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[COND_LVALUE]] to i8*
296 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
297
298 // t_var1 = min(t_var1, t_var1_reduction);
299 // CHECK: [[T_VAR1_VAL:%.+]] = load float, float* [[T_VAR1_REF]],
300 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load float, float* [[T_VAR1_PRIV]],
301 // CHECK: [[CMP:%.+]] = fcmp olt float [[T_VAR1_VAL]], [[T_VAR1_PRIV_VAL]]
302 // CHECK: br i1 [[CMP]]
303 // CHECK: [[UP:%.+]] = phi float
304 // CHECK: store float [[UP]], float* [[T_VAR1_REF]],
305
306 // __kmpc_end_reduce(<loc>, <gtid>, &<lock>);
307 // CHECK: call void @__kmpc_end_reduce(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], [8 x i32]* [[REDUCTION_LOCK]])
308
309 // break;
310 // CHECK: br label %[[RED_DONE]]
311
312 // case 2:
313 // t_var += t_var_reduction;
314 // CHECK: load float, float* [[T_VAR_PRIV]]
315 // CHECK: [[T_VAR_REF_INT:%.+]] = bitcast float* [[T_VAR_REF]] to i32*
316 // CHECK: [[OLD1:%.+]] = load atomic i32, i32* [[T_VAR_REF_INT]] monotonic,
317 // CHECK: br label %[[CONT:.+]]
318 // CHECK: [[CONT]]
319 // CHECK: [[ORIG_OLD_INT:%.+]] = phi i32 [ [[OLD1]], %{{.+}} ], [ [[OLD2:%.+]], %[[CONT]] ]
320 // CHECK: fadd float
321 // CHECK: [[UP_INT:%.+]] = load i32, i32*
322 // CHECK: [[T_VAR_REF_INT:%.+]] = bitcast float* [[T_VAR_REF]] to i32*
323 // CHECK: [[RES:%.+]] = cmpxchg i32* [[T_VAR_REF_INT]], i32 [[ORIG_OLD_INT]], i32 [[UP_INT]] monotonic monotonic
324 // CHECK: [[OLD2:%.+]] = extractvalue { i32, i1 } [[RES]], 0
325 // CHECK: [[SUCCESS_FAIL:%.+]] = extractvalue { i32, i1 } [[RES]], 1
326 // CHECK: br i1 [[SUCCESS_FAIL]], label %[[ATOMIC_DONE:.+]], label %[[CONT]]
327 // CHECK: [[ATOMIC_DONE]]
328
329 // var = var.operator &(var_reduction);
330 // CHECK: call void @__kmpc_critical(
331 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @{{.+}}([[S_FLOAT_TY]]* [[VAR_REF]], [[S_FLOAT_TY]]* dereferenceable(4) [[VAR_PRIV]])
332 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR_REF]] to i8*
333 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[UP]] to i8*
334 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
335 // CHECK: call void @__kmpc_end_critical(
336
337 // var1 = var1.operator &&(var1_reduction);
338 // CHECK: call void @__kmpc_critical(
339 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_REF]])
340 // CHECK: [[VAR1_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
341 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
342 // CHECK: [[TRUE]]
343 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_PRIV]])
344 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
345 // CHECK: br label %[[END2]]
346 // CHECK: [[END2]]
347 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
348 // CHECK: [[CONV:%.+]] = uitofp i1 [[COND_LVALUE]] to float
349 // CHECK: call void @{{.+}}([[S_FLOAT_TY]]* [[COND_LVALUE:%.+]], float [[CONV]])
350 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR1_REF]] to i8*
351 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[COND_LVALUE]] to i8*
352 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
353 // CHECK: call void @__kmpc_end_critical(
354
355 // t_var1 = min(t_var1, t_var1_reduction);
356 // CHECK: load float, float* [[T_VAR1_PRIV]]
357 // CHECK: [[T_VAR1_REF_INT:%.+]] = bitcast float* [[T_VAR1_REF]] to i32*
358 // CHECK: [[OLD1:%.+]] = load atomic i32, i32* [[T_VAR1_REF_INT]] monotonic,
359 // CHECK: br label %[[CONT:.+]]
360 // CHECK: [[CONT]]
361 // CHECK: [[ORIG_OLD_INT:%.+]] = phi i32 [ [[OLD1]], %{{.+}} ], [ [[OLD2:%.+]], %{{.+}} ]
362 // CHECK: [[CMP:%.+]] = fcmp olt float
363 // CHECK: br i1 [[CMP]]
364 // CHECK: phi float
365 // CHECK: [[UP_INT:%.+]] = load i32
366 // CHECK: [[T_VAR1_REF_INT:%.+]] = bitcast float* [[T_VAR1_REF]] to i32*
367 // CHECK: [[RES:%.+]] = cmpxchg i32* [[T_VAR1_REF_INT]], i32 [[ORIG_OLD_INT]], i32 [[UP_INT]] monotonic monotonic
368 // CHECK: [[OLD2:%.+]] = extractvalue { i32, i1 } [[RES]], 0
369 // CHECK: [[SUCCESS_FAIL:%.+]] = extractvalue { i32, i1 } [[RES]], 1
370 // CHECK: br i1 [[SUCCESS_FAIL]], label %[[ATOMIC_DONE:.+]], label %[[CONT]]
371 // CHECK: [[ATOMIC_DONE]]
372
373 // __kmpc_end_reduce(<loc>, <gtid>, &<lock>);
374 // CHECK: call void @__kmpc_end_reduce(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], [8 x i32]* [[REDUCTION_LOCK]])
375
376 // break;
377 // CHECK: br label %[[RED_DONE]]
378 // CHECK: [[RED_DONE]]
379 // CHECK-DAG: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
380 // CHECK-DAG: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
381 // CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
382
383 // CHECK: ret void
384
385 // void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
386 // *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
387 // ...
388 // *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
389 // *(Type<n>-1*)rhs[<n>-1]);
390 // }
391 // CHECK: define internal void [[REDUCTION_FUNC]](i8*, i8*)
392 // t_var_lhs = (float*)lhs[0];
393 // CHECK: [[T_VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS:%.+]], i64 0, i64 0
394 // CHECK: [[T_VAR_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR_RHS_REF]],
395 // CHECK: [[T_VAR_RHS:%.+]] = bitcast i8* [[T_VAR_RHS_VOID]] to float*
396 // t_var_rhs = (float*)rhs[0];
397 // CHECK: [[T_VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS:%.+]], i64 0, i64 0
398 // CHECK: [[T_VAR_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR_LHS_REF]],
399 // CHECK: [[T_VAR_LHS:%.+]] = bitcast i8* [[T_VAR_LHS_VOID]] to float*
400
401 // var_lhs = (S<float>*)lhs[1];
402 // CHECK: [[VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 1
403 // CHECK: [[VAR_RHS_VOID:%.+]] = load i8*, i8** [[VAR_RHS_REF]],
404 // CHECK: [[VAR_RHS:%.+]] = bitcast i8* [[VAR_RHS_VOID]] to [[S_FLOAT_TY]]*
405 // var_rhs = (S<float>*)rhs[1];
406 // CHECK: [[VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 1
407 // CHECK: [[VAR_LHS_VOID:%.+]] = load i8*, i8** [[VAR_LHS_REF]],
408 // CHECK: [[VAR_LHS:%.+]] = bitcast i8* [[VAR_LHS_VOID]] to [[S_FLOAT_TY]]*
409
410 // var1_lhs = (S<float>*)lhs[2];
411 // CHECK: [[VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 2
412 // CHECK: [[VAR1_RHS_VOID:%.+]] = load i8*, i8** [[VAR1_RHS_REF]],
413 // CHECK: [[VAR1_RHS:%.+]] = bitcast i8* [[VAR1_RHS_VOID]] to [[S_FLOAT_TY]]*
414 // var1_rhs = (S<float>*)rhs[2];
415 // CHECK: [[VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 2
416 // CHECK: [[VAR1_LHS_VOID:%.+]] = load i8*, i8** [[VAR1_LHS_REF]],
417 // CHECK: [[VAR1_LHS:%.+]] = bitcast i8* [[VAR1_LHS_VOID]] to [[S_FLOAT_TY]]*
418
419 // t_var1_lhs = (float*)lhs[3];
420 // CHECK: [[T_VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 3
421 // CHECK: [[T_VAR1_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_RHS_REF]],
422 // CHECK: [[T_VAR1_RHS:%.+]] = bitcast i8* [[T_VAR1_RHS_VOID]] to float*
423 // t_var1_rhs = (float*)rhs[3];
424 // CHECK: [[T_VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 3
425 // CHECK: [[T_VAR1_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_LHS_REF]],
426 // CHECK: [[T_VAR1_LHS:%.+]] = bitcast i8* [[T_VAR1_LHS_VOID]] to float*
427
428 // t_var_lhs += t_var_rhs;
429 // CHECK: [[T_VAR_LHS_VAL:%.+]] = load float, float* [[T_VAR_LHS]],
430 // CHECK: [[T_VAR_RHS_VAL:%.+]] = load float, float* [[T_VAR_RHS]],
431 // CHECK: [[UP:%.+]] = fadd float [[T_VAR_LHS_VAL]], [[T_VAR_RHS_VAL]]
432 // CHECK: store float [[UP]], float* [[T_VAR_LHS]],
433
434 // var_lhs = var_lhs.operator &(var_rhs);
435 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @{{.+}}([[S_FLOAT_TY]]* [[VAR_LHS]], [[S_FLOAT_TY]]* dereferenceable(4) [[VAR_RHS]])
436 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR_LHS]] to i8*
437 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[UP]] to i8*
438 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
439
440 // var1_lhs = var1_lhs.operator &&(var1_rhs);
441 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_LHS]])
442 // CHECK: [[VAR1_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
443 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
444 // CHECK: [[TRUE]]
445 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_RHS]])
446 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
447 // CHECK: br label %[[END2]]
448 // CHECK: [[END2]]
449 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
450 // CHECK: [[CONV:%.+]] = uitofp i1 [[COND_LVALUE]] to float
451 // CHECK: call void @{{.+}}([[S_FLOAT_TY]]* [[COND_LVALUE:%.+]], float [[CONV]])
452 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR1_LHS]] to i8*
453 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[COND_LVALUE]] to i8*
454 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
455
456 // t_var1_lhs = min(t_var1_lhs, t_var1_rhs);
457 // CHECK: [[T_VAR1_LHS_VAL:%.+]] = load float, float* [[T_VAR1_LHS]],
458 // CHECK: [[T_VAR1_RHS_VAL:%.+]] = load float, float* [[T_VAR1_RHS]],
459 // CHECK: [[CMP:%.+]] = fcmp olt float [[T_VAR1_LHS_VAL]], [[T_VAR1_RHS_VAL]]
460 // CHECK: br i1 [[CMP]]
461 // CHECK: [[UP:%.+]] = phi float
462 // CHECK: store float [[UP]], float* [[T_VAR1_LHS]],
463 // CHECK: ret void
464
465 // CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* nonnull %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY]]]]* dereferenceable(160) %{{.+}})
466
467 // Reduction list for runtime.
468 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
469
470 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
471
472 // CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
473 // CHECK: [[LB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
474 // CHECK: [[LB1_0:%.+]] = getelementptr inbounds i32, i32* [[LB1]], i64 0
475 // CHECK: [[IDX1:%.+]] = mul nsw i64 1, %{{.+}}
476 // CHECK: [[UB1:%.+]] = getelementptr inbounds i32, i32* %{{.+}}, i64 [[IDX1]]
477 // CHECK: [[UB1_UP:%.+]] = getelementptr inbounds i32, i32* [[UB1]], i64 %
478 // CHECK: [[UB_CAST:%.+]] = ptrtoint i32* [[UB1_UP]] to i64
479 // CHECK: [[LB_CAST:%.+]] = ptrtoint i32* [[LB1_0]] to i64
480 // CHECK: [[DIFF:%.+]] = sub i64 [[UB_CAST]], [[LB_CAST]]
481 // CHECK: [[SIZE_1:%.+]] = sdiv exact i64 [[DIFF]], ptrtoint (i32* getelementptr (i32, i32* null, i32 1) to i64)
482 // CHECK: [[ARR_SIZE:%.+]] = add nuw i64 [[SIZE_1]], 1
483 // CHECK: call i8* @llvm.stacksave()
484 // CHECK: [[ARR_PRIV:%.+]] = alloca i32, i64 [[ARR_SIZE]],
485
486 // Check initialization of private copy.
487 // CHECK: [[END:%.+]] = getelementptr i32, i32* [[ARR_PRIV]], i64 [[ARR_SIZE]]
488 // CHECK: [[ISEMPTY:%.+]] = icmp eq i32* [[ARR_PRIV]], [[END]]
489 // CHECK: br i1 [[ISEMPTY]],
490 // CHECK: phi i32*
491 // CHECK: store i32 0, i32* %
492 // CHECK: [[DONE:%.+]] = icmp eq i32* %{{.+}}, [[END]]
493 // CHECK: br i1 [[DONE]],
494
495 // CHECK: [[ARRS_PRIV:%.+]] = alloca [[S_FLOAT_TY]], i64 [[ARRS_SIZE:%.+]],
496
497 // Check initialization of private copy.
498 // CHECK: [[END:%.+]] = getelementptr [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[ARRS_PRIV]], i64 [[ARRS_SIZE]]
499 // CHECK: [[ISEMPTY:%.+]] = icmp eq [[S_FLOAT_TY]]* [[ARRS_PRIV]], [[END]]
500 // CHECK: br i1 [[ISEMPTY]],
501 // CHECK: phi [[S_FLOAT_TY]]*
502 // CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* %
503 // CHECK: [[DONE:%.+]] = icmp eq [[S_FLOAT_TY]]* %{{.+}}, [[END]]
504 // CHECK: br i1 [[DONE]],
505
506 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
507 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
508 // CHECK: call void @__kmpc_for_static_init_4(
509 // Skip checks for internal operations.
510 // CHECK: call void @__kmpc_for_static_fini(
511
512 // void *RedList[<n>] = {<ReductionVars>[0], ..., <ReductionVars>[<n>-1]};
513
514 // CHECK: [[ARR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 0
515 // CHECK: [[BITCAST:%.+]] = bitcast i32* [[ARR_PRIV]] to i8*
516 // CHECK: store i8* [[BITCAST]], i8** [[ARR_PRIV_REF]],
517 // CHECK: [[ARR_SIZE_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 1
518 // CHECK: [[BITCAST:%.+]] = inttoptr i64 [[ARR_SIZE]] to i8*
519 // CHECK: store i8* [[BITCAST]], i8** [[ARR_SIZE_REF]],
520 // CHECK: [[ARRS_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 2
521 // CHECK: [[BITCAST:%.+]] = bitcast [[S_FLOAT_TY]]* [[ARRS_PRIV]] to i8*
522 // CHECK: store i8* [[BITCAST]], i8** [[ARRS_PRIV_REF]],
523 // CHECK: [[ARRS_SIZE_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 3
524 // CHECK: [[BITCAST:%.+]] = inttoptr i64 [[ARRS_SIZE]] to i8*
525 // CHECK: store i8* [[BITCAST]], i8** [[ARRS_SIZE_REF]],
526
527 // res = __kmpc_reduce(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>);
528
529 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
530 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
531 // CHECK: [[BITCAST:%.+]] = bitcast [4 x i8*]* [[RED_LIST]] to i8*
532 // CHECK: [[RES:%.+]] = call i32 @__kmpc_reduce_nowait(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], i32 2, i64 32, i8* [[BITCAST]], void (i8*, i8*)* [[REDUCTION_FUNC:@.+]], [8 x i32]* [[REDUCTION_LOCK]])
533
534 // switch(res)
535 // CHECK: switch i32 [[RES]], label %[[RED_DONE:.+]] [
536 // CHECK: i32 1, label %[[CASE1:.+]]
537 // CHECK: i32 2, label %[[CASE2:.+]]
538 // CHECK: ]
539
540 // case 1:
541 // CHECK: [[CASE1]]
542
543 // arr[:] += arr_reduction[:];
544 // CHECK: [[END:%.+]] = getelementptr i32, i32* [[LB1_0]], i64 [[ARR_SIZE]]
545 // CHECK: [[ISEMPTY:%.+]] = icmp eq i32* [[LB1_0]], [[END]]
546 // CHECK: br i1 [[ISEMPTY]],
547 // CHECK: phi i32*
548 // CHECK: [[ADD:%.+]] = add nsw i32 %
549 // CHECK: store i32 [[ADD]], i32* %
550 // CHECK: [[DONE:%.+]] = icmp eq i32* %{{.+}}, [[END]]
551 // CHECK: br i1 [[DONE]],
552
553 // arrs[:] = var.operator &(arrs_reduction[:]);
554 // CHECK: [[END:%.+]] = getelementptr [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[ARRS_LB:%.+]], i64 [[ARRS_SIZE]]
555 // CHECK: [[ISEMPTY:%.+]] = icmp eq [[S_FLOAT_TY]]* [[ARRS_LB]], [[END]]
556 // CHECK: br i1 [[ISEMPTY]],
557 // CHECK: phi [[S_FLOAT_TY]]*
558 // CHECK: [[AND:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @_ZN1SIfEanERKS0_([[S_FLOAT_TY]]* %{{.+}}, [[S_FLOAT_TY]]* dereferenceable(4) %{{.+}})
559 // CHECK: [[BITCAST:%.+]] = bitcast [[S_FLOAT_TY]]* [[AND]] to i8*
560 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{.+}}, i8* [[BITCAST]], i64 4, i32 4, i1 false)
561 // CHECK: [[DONE:%.+]] = icmp eq [[S_FLOAT_TY]]* %{{.+}}, [[END]]
562 // CHECK: br i1 [[DONE]],
563
564 // __kmpc_end_reduce(<loc>, <gtid>, &<lock>);
565 // CHECK: call void @__kmpc_end_reduce_nowait(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], [8 x i32]* [[REDUCTION_LOCK]])
566
567 // break;
568 // CHECK: br label %[[RED_DONE]]
569
570 // case 2:
571 // CHECK: [[CASE2]]
572
573 // arr[:] += arr_reduction[:];
574 // CHECK: [[END:%.+]] = getelementptr i32, i32* [[LB1_0]], i64 [[ARR_SIZE]]
575 // CHECK: [[ISEMPTY:%.+]] = icmp eq i32* [[LB1_0]], [[END]]
576 // CHECK: br i1 [[ISEMPTY]],
577 // CHECK: phi i32*
578 // CHECK: atomicrmw add i32* %{{.+}}, i32 %{{.+}} monotonic
579 // CHECK: [[DONE:%.+]] = icmp eq i32* %{{.+}}, [[END]]
580 // CHECK: br i1 [[DONE]],
581
582 // arrs[:] = var.operator &(arrs_reduction[:]);
583 // CHECK: [[END:%.+]] = getelementptr [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[ARRS_LB:%.+]], i64 [[ARRS_SIZE]]
584 // CHECK: [[ISEMPTY:%.+]] = icmp eq [[S_FLOAT_TY]]* [[ARRS_LB]], [[END]]
585 // CHECK: br i1 [[ISEMPTY]],
586 // CHECK: phi [[S_FLOAT_TY]]*
587 // CHECK: call void @__kmpc_critical(
588 // CHECK: [[AND:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @_ZN1SIfEanERKS0_([[S_FLOAT_TY]]* %{{.+}}, [[S_FLOAT_TY]]* dereferenceable(4) %{{.+}})
589 // CHECK: [[BITCAST:%.+]] = bitcast [[S_FLOAT_TY]]* [[AND]] to i8*
590 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{.+}}, i8* [[BITCAST]], i64 4, i32 4, i1 false)
591 // CHECK: call void @__kmpc_end_critical(
592 // CHECK: [[DONE:%.+]] = icmp eq [[S_FLOAT_TY]]* %{{.+}}, [[END]]
593 // CHECK: br i1 [[DONE]],
594
595 // break;
596 // CHECK: br label %[[RED_DONE]]
597 // CHECK: [[RED_DONE]]
598
599 // Check destruction of private copy.
600 // CHECK: [[END:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[ARRS_PRIV]], i64 [[ARRS_SIZE]]
601 // CHECK: [[ISEMPTY:%.+]] = icmp eq [[S_FLOAT_TY]]* [[ARRS_PRIV]], [[END]]
602 // CHECK: br i1 [[ISEMPTY]],
603 // CHECK: phi [[S_FLOAT_TY]]*
604 // CHECK: call void @_ZN1SIfED1Ev([[S_FLOAT_TY]]* %
605 // CHECK: [[DONE:%.+]] = icmp eq [[S_FLOAT_TY]]* %{{.+}}, [[ARRS_PRIV]]
606 // CHECK: br i1 [[DONE]],
607 // CHECK: call void @llvm.stackrestore(i8*
608
609 // CHECK: ret void
610
611 // void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
612 // *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
613 // ...
614 // *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
615 // *(Type<n>-1*)rhs[<n>-1]);
616 // }
617 // CHECK: define internal void [[REDUCTION_FUNC]](i8*, i8*)
618 // arr_rhs = (int*)rhs[0];
619 // CHECK: [[ARR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS:%.+]], i64 0, i64 0
620 // CHECK: [[ARR_RHS_VOID:%.+]] = load i8*, i8** [[ARR_RHS_REF]],
621 // CHECK: [[ARR_RHS:%.+]] = bitcast i8* [[ARR_RHS_VOID]] to i32*
622 // arr_lhs = (int*)lhs[0];
623 // CHECK: [[ARR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS:%.+]], i64 0, i64 0
624 // CHECK: [[ARR_LHS_VOID:%.+]] = load i8*, i8** [[ARR_LHS_REF]],
625 // CHECK: [[ARR_LHS:%.+]] = bitcast i8* [[ARR_LHS_VOID]] to i32*
626
627 // arr_size = (size_t)lhs[1];
628 // CHECK: [[ARR_SIZE_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 1
629 // CHECK: [[ARR_SIZE_VOID:%.+]] = load i8*, i8** [[ARR_SIZE_REF]],
630 // CHECK: [[ARR_SIZE:%.+]] = ptrtoint i8* [[ARR_SIZE_VOID]] to i64
631
632 // arrs_rhs = (S<float>*)rhs[2];
633 // CHECK: [[ARRS_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 2
634 // CHECK: [[ARRS_RHS_VOID:%.+]] = load i8*, i8** [[ARRS_RHS_REF]],
635 // CHECK: [[ARRS_RHS:%.+]] = bitcast i8* [[ARRS_RHS_VOID]] to [[S_FLOAT_TY]]*
636 // arrs_lhs = (S<float>*)lhs[2];
637 // CHECK: [[ARRS_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 2
638 // CHECK: [[ARRS_LHS_VOID:%.+]] = load i8*, i8** [[ARRS_LHS_REF]],
639 // CHECK: [[ARRS_LHS:%.+]] = bitcast i8* [[ARRS_LHS_VOID]] to [[S_FLOAT_TY]]*
640
641 // arrs_size = (size_t)lhs[3];
642 // CHECK: [[ARRS_SIZE_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 3
643 // CHECK: [[ARRS_SIZE_VOID:%.+]] = load i8*, i8** [[ARRS_SIZE_REF]],
644 // CHECK: [[ARRS_SIZE:%.+]] = ptrtoint i8* [[ARRS_SIZE_VOID]] to i64
645
646 // arr_lhs[:] += arr_rhs[:];
647 // CHECK: [[END:%.+]] = getelementptr i32, i32* [[ARR_LHS]], i64 [[ARR_SIZE]]
648 // CHECK: [[ISEMPTY:%.+]] = icmp eq i32* [[ARR_LHS]], [[END]]
649 // CHECK: br i1 [[ISEMPTY]],
650 // CHECK: phi i32*
651 // CHECK: [[ADD:%.+]] = add nsw i32 %
652 // CHECK: store i32 [[ADD]], i32* %
653 // CHECK: [[DONE:%.+]] = icmp eq i32* %{{.+}}, [[END]]
654 // CHECK: br i1 [[DONE]],
655
656 // arrs_lhs = arrs_lhs.operator &(arrs_rhs);
657 // CHECK: [[END:%.+]] = getelementptr [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[ARRS_LB:%.+]], i64 [[ARRS_SIZE]]
658 // CHECK: [[ISEMPTY:%.+]] = icmp eq [[S_FLOAT_TY]]* [[ARRS_LB]], [[END]]
659 // CHECK: br i1 [[ISEMPTY]],
660 // CHECK: phi [[S_FLOAT_TY]]*
661 // CHECK: [[AND:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @_ZN1SIfEanERKS0_([[S_FLOAT_TY]]* %{{.+}}, [[S_FLOAT_TY]]* dereferenceable(4) %{{.+}})
662 // CHECK: [[BITCAST:%.+]] = bitcast [[S_FLOAT_TY]]* [[AND]] to i8*
663 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{.+}}, i8* [[BITCAST]], i64 4, i32 4, i1 false)
664 // CHECK: [[DONE:%.+]] = icmp eq [[S_FLOAT_TY]]* %{{.+}}, [[END]]
665 // CHECK: br i1 [[DONE]],
666
667 // CHECK: ret void
668
669 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
670 // CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
671 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* [[TEST]])
672 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 6, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, i32*, [[S_INT_TY]]*, [[S_INT_TY]]*, i32*, [2 x i32]*, [2 x [[S_INT_TY]]]*)* [[TMAIN_MICROTASK:@.+]] to void
673 // CHECK: call {{.*}} [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
674 // CHECK: ret
675 //
676 // CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i32* dereferenceable(4) %{{.+}}, [[S_INT_TY]]* dereferenceable(4) %{{.+}}, [[S_INT_TY]]* dereferenceable(4) %{{.+}}, i32* dereferenceable(4) %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [2 x [[S_INT_TY]]]* dereferenceable(8) %{{.+}})
677 // CHECK: alloca i{{[0-9]+}},
678 // CHECK: alloca i{{[0-9]+}},
679 // CHECK: alloca i{{[0-9]+}},
680 // CHECK: alloca i{{[0-9]+}},
681 // CHECK: alloca i{{[0-9]+}},
682 // CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
683 // CHECK: [[VAR_PRIV:%.+]] = alloca [[S_INT_TY]],
684 // CHECK: [[VAR1_PRIV:%.+]] = alloca [[S_INT_TY]],
685 // CHECK: [[T_VAR1_PRIV:%.+]] = alloca i{{[0-9]+}},
686
687 // Reduction list for runtime.
688 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
689
690 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
691
692 // CHECK: [[T_VAR_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
693 // CHECK: [[VAR1_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
694 // CHECK: [[T_VAR1_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
695
696 // For + reduction operation initial value of private variable is 0.
697 // CHECK: store i{{[0-9]+}} 0, i{{[0-9]+}}* [[T_VAR_PRIV]],
698
699 // For & reduction operation initial value of private variable is ones in all bits.
700 // CHECK: [[VAR_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
701 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* [[VAR_PRIV]])
702
703 // For && reduction operation initial value of private variable is 1.0.
704 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* [[VAR1_PRIV]])
705
706 // For min reduction operation initial value of private variable is largest repesentable value.
707 // CHECK: store i{{[0-9]+}} 2147483647, i{{[0-9]+}}* [[T_VAR1_PRIV]],
708
709 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
710 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
711 // CHECK: call void @__kmpc_for_static_init_4(
712 // Skip checks for internal operations.
713 // CHECK: call void @__kmpc_for_static_fini(
714
715 // void *RedList[<n>] = {<ReductionVars>[0], ..., <ReductionVars>[<n>-1]};
716
717 // CHECK: [[T_VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 0
718 // CHECK: [[BITCAST:%.+]] = bitcast i{{[0-9]+}}* [[T_VAR_PRIV]] to i8*
719 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR_PRIV_REF]],
720 // CHECK: [[VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 1
721 // CHECK: [[BITCAST:%.+]] = bitcast [[S_INT_TY]]* [[VAR_PRIV]] to i8*
722 // CHECK: store i8* [[BITCAST]], i8** [[VAR_PRIV_REF]],
723 // CHECK: [[VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 2
724 // CHECK: [[BITCAST:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_PRIV]] to i8*
725 // CHECK: store i8* [[BITCAST]], i8** [[VAR1_PRIV_REF]],
726 // CHECK: [[T_VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 3
727 // CHECK: [[BITCAST:%.+]] = bitcast i{{[0-9]+}}* [[T_VAR1_PRIV]] to i8*
728 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR1_PRIV_REF]],
729
730 // res = __kmpc_reduce_nowait(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>);
731
732 // CHECK: [[BITCAST:%.+]] = bitcast [4 x i8*]* [[RED_LIST]] to i8*
733 // CHECK: [[RES:%.+]] = call i32 @__kmpc_reduce_nowait(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], i32 4, i64 32, i8* [[BITCAST]], void (i8*, i8*)* [[REDUCTION_FUNC:@.+]], [8 x i32]* [[REDUCTION_LOCK]])
734
735 // switch(res)
736 // CHECK: switch i32 [[RES]], label %[[RED_DONE:.+]] [
737 // CHECK: i32 1, label %[[CASE1:.+]]
738 // CHECK: i32 2, label %[[CASE2:.+]]
739 // CHECK: ]
740
741 // case 1:
742 // t_var += t_var_reduction;
743 // CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_REF]],
744 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]],
745 // CHECK: [[UP:%.+]] = add nsw i{{[0-9]+}} [[T_VAR_VAL]], [[T_VAR_PRIV_VAL]]
746 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR_REF]],
747
748 // var = var.operator &(var_reduction);
749 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* [[VAR_REF]], [[S_INT_TY]]* dereferenceable(4) [[VAR_PRIV]])
750 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_REF]] to i8*
751 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
752 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
753
754 // var1 = var1.operator &&(var1_reduction);
755 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_REF]])
756 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
757 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
758 // CHECK: [[TRUE]]
759 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_PRIV]])
760 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
761 // CHECK: br label %[[END2]]
762 // CHECK: [[END2]]
763 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
764 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
765 // CHECK: call void @{{.+}}([[S_INT_TY]]* [[COND_LVALUE:%.+]], i32 [[CONV]])
766 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_REF]] to i8*
767 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
768 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
769
770 // t_var1 = min(t_var1, t_var1_reduction);
771 // CHECK: [[T_VAR1_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_REF]],
772 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_PRIV]],
773 // CHECK: [[CMP:%.+]] = icmp slt i{{[0-9]+}} [[T_VAR1_VAL]], [[T_VAR1_PRIV_VAL]]
774 // CHECK: br i1 [[CMP]]
775 // CHECK: [[UP:%.+]] = phi i32
776 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR1_REF]],
777
778 // __kmpc_end_reduce_nowait(<loc>, <gtid>, &<lock>);
779 // CHECK: call void @__kmpc_end_reduce_nowait(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], [8 x i32]* [[REDUCTION_LOCK]])
780
781 // break;
782 // CHECK: br label %[[RED_DONE]]
783
784 // case 2:
785 // t_var += t_var_reduction;
786 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]]
787 // CHECK: atomicrmw add i32* [[T_VAR_REF]], i32 [[T_VAR_PRIV_VAL]] monotonic
788
789 // var = var.operator &(var_reduction);
790 // CHECK: call void @__kmpc_critical(
791 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* [[VAR_REF]], [[S_INT_TY]]* dereferenceable(4) [[VAR_PRIV]])
792 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_REF]] to i8*
793 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
794 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
795 // CHECK: call void @__kmpc_end_critical(
796
797 // var1 = var1.operator &&(var1_reduction);
798 // CHECK: call void @__kmpc_critical(
799 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_REF]])
800 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
801 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
802 // CHECK: [[TRUE]]
803 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_PRIV]])
804 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
805 // CHECK: br label %[[END2]]
806 // CHECK: [[END2]]
807 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
808 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
809 // CHECK: call void @{{.+}}([[S_INT_TY]]* [[COND_LVALUE:%.+]], i32 [[CONV]])
810 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_REF]] to i8*
811 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
812 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
813 // CHECK: call void @__kmpc_end_critical(
814
815 // t_var1 = min(t_var1, t_var1_reduction);
816 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_PRIV]]
817 // CHECK: atomicrmw min i32* [[T_VAR1_REF]], i32 [[T_VAR1_PRIV_VAL]] monotonic
818
819 // break;
820 // CHECK: br label %[[RED_DONE]]
821 // CHECK: [[RED_DONE]]
822 // CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]* [[VAR_PRIV]])
823 // CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]*
824 // CHECK: ret void
825
826 // void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
827 // *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
828 // ...
829 // *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
830 // *(Type<n>-1*)rhs[<n>-1]);
831 // }
832 // CHECK: define internal void [[REDUCTION_FUNC]](i8*, i8*)
833 // t_var_lhs = (i{{[0-9]+}}*)lhs[0];
834 // CHECK: [[T_VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS:%.+]], i64 0, i64 0
835 // CHECK: [[T_VAR_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR_RHS_REF]],
836 // CHECK: [[T_VAR_RHS:%.+]] = bitcast i8* [[T_VAR_RHS_VOID]] to i{{[0-9]+}}*
837 // t_var_rhs = (i{{[0-9]+}}*)rhs[0];
838 // CHECK: [[T_VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS:%.+]], i64 0, i64 0
839 // CHECK: [[T_VAR_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR_LHS_REF]],
840 // CHECK: [[T_VAR_LHS:%.+]] = bitcast i8* [[T_VAR_LHS_VOID]] to i{{[0-9]+}}*
841
842 // var_lhs = (S<i{{[0-9]+}}>*)lhs[1];
843 // CHECK: [[VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 1
844 // CHECK: [[VAR_RHS_VOID:%.+]] = load i8*, i8** [[VAR_RHS_REF]],
845 // CHECK: [[VAR_RHS:%.+]] = bitcast i8* [[VAR_RHS_VOID]] to [[S_INT_TY]]*
846 // var_rhs = (S<i{{[0-9]+}}>*)rhs[1];
847 // CHECK: [[VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 1
848 // CHECK: [[VAR_LHS_VOID:%.+]] = load i8*, i8** [[VAR_LHS_REF]],
849 // CHECK: [[VAR_LHS:%.+]] = bitcast i8* [[VAR_LHS_VOID]] to [[S_INT_TY]]*
850
851 // var1_lhs = (S<i{{[0-9]+}}>*)lhs[2];
852 // CHECK: [[VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 2
853 // CHECK: [[VAR1_RHS_VOID:%.+]] = load i8*, i8** [[VAR1_RHS_REF]],
854 // CHECK: [[VAR1_RHS:%.+]] = bitcast i8* [[VAR1_RHS_VOID]] to [[S_INT_TY]]*
855 // var1_rhs = (S<i{{[0-9]+}}>*)rhs[2];
856 // CHECK: [[VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 2
857 // CHECK: [[VAR1_LHS_VOID:%.+]] = load i8*, i8** [[VAR1_LHS_REF]],
858 // CHECK: [[VAR1_LHS:%.+]] = bitcast i8* [[VAR1_LHS_VOID]] to [[S_INT_TY]]*
859
860 // t_var1_lhs = (i{{[0-9]+}}*)lhs[3];
861 // CHECK: [[T_VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 3
862 // CHECK: [[T_VAR1_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_RHS_REF]],
863 // CHECK: [[T_VAR1_RHS:%.+]] = bitcast i8* [[T_VAR1_RHS_VOID]] to i{{[0-9]+}}*
864 // t_var1_rhs = (i{{[0-9]+}}*)rhs[3];
865 // CHECK: [[T_VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 3
866 // CHECK: [[T_VAR1_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_LHS_REF]],
867 // CHECK: [[T_VAR1_LHS:%.+]] = bitcast i8* [[T_VAR1_LHS_VOID]] to i{{[0-9]+}}*
868
869 // t_var_lhs += t_var_rhs;
870 // CHECK: [[T_VAR_LHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_LHS]],
871 // CHECK: [[T_VAR_RHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_RHS]],
872 // CHECK: [[UP:%.+]] = add nsw i{{[0-9]+}} [[T_VAR_LHS_VAL]], [[T_VAR_RHS_VAL]]
873 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR_LHS]],
874
875 // var_lhs = var_lhs.operator &(var_rhs);
876 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* [[VAR_LHS]], [[S_INT_TY]]* dereferenceable(4) [[VAR_RHS]])
877 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_LHS]] to i8*
878 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
879 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
880
881 // var1_lhs = var1_lhs.operator &&(var1_rhs);
882 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_LHS]])
883 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
884 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
885 // CHECK: [[TRUE]]
886 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_RHS]])
887 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
888 // CHECK: br label %[[END2]]
889 // CHECK: [[END2]]
890 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
891 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
892 // CHECK: call void @{{.+}}([[S_INT_TY]]* [[COND_LVALUE:%.+]], i32 [[CONV]])
893 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_LHS]] to i8*
894 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
895 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
896
897 // t_var1_lhs = min(t_var1_lhs, t_var1_rhs);
898 // CHECK: [[T_VAR1_LHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_LHS]],
899 // CHECK: [[T_VAR1_RHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_RHS]],
900 // CHECK: [[CMP:%.+]] = icmp slt i{{[0-9]+}} [[T_VAR1_LHS_VAL]], [[T_VAR1_RHS_VAL]]
901 // CHECK: br i1 [[CMP]]
902 // CHECK: [[UP:%.+]] = phi i32
903 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR1_LHS]],
904 // CHECK: ret void
905
906 #endif
907
908