1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %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 -allow-deprecated-dag-overlap %s
4 // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap -check-prefix=LAMBDA %s
5 // RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap -check-prefix=BLOCKS %s
6
7 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
8 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-apple-darwin10 -emit-pch -o %t %s
9 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
10 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DLAMBDA -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
11 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY0 %s
12 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
13 // expected-no-diagnostics
14 #ifndef HEADER
15 #define HEADER
16
17 volatile double g;
18
19 template <class T>
20 struct S {
21 T f;
SS22 S(T a) : f(a + g) {}
SS23 S() : f(g) {}
operator TS24 operator T() { return T(); }
operator &S25 S &operator&(const S &) { return *this; }
~SS26 ~S() {}
27 };
28
29 // CHECK-DAG: [[S_FLOAT_TY:%.+]] = type { float }
30 // CHECK-DAG: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }
31 // CHECK-DAG: [[ATOMIC_REDUCE_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 18, i32 0, i32 0, i8*
32 // CHECK-DAG: [[REDUCTION_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 18, i32 0, i32 0, i8*
33 // CHECK-DAG: [[REDUCTION_LOCK:@.+]] = common global [8 x i32] zeroinitializer
34
35 template <typename T>
tmain()36 T tmain() {
37 T t;
38 S<T> test;
39 T t_var = T(), t_var1;
40 T vec[] = {1, 2};
41 S<T> s_arr[] = {1, 2};
42 S<T> var(3), var1;
43 #pragma omp parallel
44 #pragma omp sections reduction(+:t_var) reduction(&:var) reduction(&& : var1) reduction(min: t_var1) nowait
45 {
46 vec[0] = t_var;
47 #pragma omp section
48 s_arr[0] = var;
49 }
50 return T();
51 }
52
main()53 int main() {
54 #ifdef LAMBDA
55 // LAMBDA: [[G:@.+]] = global double
56 // LAMBDA-LABEL: @main
57 // LAMBDA: call void [[OUTER_LAMBDA:@.+]](
58 [&]() {
59 // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
60 // LAMBDA: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
61 #pragma omp parallel
62 #pragma omp sections reduction(+:g)
63 {
64 // LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}})
65 // LAMBDA: [[G_PRIVATE_ADDR:%.+]] = alloca double,
66
67 // Reduction list for runtime.
68 // LAMBDA: [[RED_LIST:%.+]] = alloca [1 x i8*],
69
70 // LAMBDA: store double 0.0{{.+}}, double* [[G_PRIVATE_ADDR]]
71 // LAMBDA: call void @__kmpc_for_static_init_4(
72 g = 1;
73 // LAMBDA: store double 1.0{{.+}}, double* [[G_PRIVATE_ADDR]],
74 // LAMBDA: [[G_PRIVATE_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
75 // LAMBDA: store double* [[G_PRIVATE_ADDR]], double** [[G_PRIVATE_ADDR_REF]]
76 // LAMBDA: call void [[INNER_LAMBDA:@.+]](%{{.+}}* {{[^,]*}} [[ARG]])
77 // LAMBDA: call void @__kmpc_for_static_fini(
78
79 // LAMBDA: [[G_PRIV_REF:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[RED_LIST]], i64 0, i64 0
80 // LAMBDA: [[BITCAST:%.+]] = bitcast double* [[G_PRIVATE_ADDR]] to i8*
81 // LAMBDA: store i8* [[BITCAST]], i8** [[G_PRIV_REF]],
82 // LAMBDA: call i32 @__kmpc_reduce(
83 // LAMBDA: switch i32 %{{.+}}, label %[[REDUCTION_DONE:.+]] [
84 // LAMBDA: i32 1, label %[[CASE1:.+]]
85 // LAMBDA: i32 2, label %[[CASE2:.+]]
86 // LAMBDA: [[CASE1]]
87 // LAMBDA: [[G_VAL:%.+]] = load double, double* [[G]]
88 // LAMBDA: [[G_PRIV_VAL:%.+]] = load double, double* [[G_PRIVATE_ADDR]]
89 // LAMBDA: [[ADD:%.+]] = fadd double [[G_VAL]], [[G_PRIV_VAL]]
90 // LAMBDA: store double [[ADD]], double* [[G]]
91 // LAMBDA: call void @__kmpc_end_reduce(
92 // LAMBDA: br label %[[REDUCTION_DONE]]
93 // LAMBDA: [[CASE2]]
94 // LAMBDA: [[G_PRIV_VAL:%.+]] = load double, double* [[G_PRIVATE_ADDR]]
95 // LAMBDA: fadd double
96 // LAMBDA: cmpxchg i64*
97 // LAMBDA: call void @__kmpc_end_reduce(
98 // LAMBDA: br label %[[REDUCTION_DONE]]
99 // LAMBDA: [[REDUCTION_DONE]]
100 // LAMBDA: ret void
101 #pragma omp section
102 [&]() {
103 // LAMBDA: define {{.+}} void [[INNER_LAMBDA]](%{{.+}}* {{[^,]*}} [[ARG_PTR:%.+]])
104 // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
105 g = 2;
106 // LAMBDA: [[ARG_PTR:%.+]] = load %{{.+}}*, %{{.+}}** [[ARG_PTR_REF]]
107 // LAMBDA: [[G_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
108 // LAMBDA: [[G_REF:%.+]] = load double*, double** [[G_PTR_REF]]
109 // LAMBDA: store double 2.0{{.+}}, double* [[G_REF]]
110 }();
111 }
112 }();
113 return 0;
114 #elif defined(BLOCKS)
115 // BLOCKS: [[G:@.+]] = global double
116 // BLOCKS-LABEL: @main
117 // BLOCKS: call void {{%.+}}(i8
118 ^{
119 // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
120 // BLOCKS: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
121 #pragma omp parallel
122 #pragma omp sections reduction(-:g)
123 {
124 // BLOCKS: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}})
125 // BLOCKS: [[G_PRIVATE_ADDR:%.+]] = alloca double,
126
127 // Reduction list for runtime.
128 // BLOCKS: [[RED_LIST:%.+]] = alloca [1 x i8*],
129
130 // BLOCKS: store double 0.0{{.+}}, double* [[G_PRIVATE_ADDR]]
131 g = 1;
132 // BLOCKS: call void @__kmpc_for_static_init_4(
133 // BLOCKS: store double 1.0{{.+}}, double* [[G_PRIVATE_ADDR]],
134 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
135 // BLOCKS: double* [[G_PRIVATE_ADDR]]
136 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
137 // BLOCKS: call void {{%.+}}(i8
138 // BLOCKS: call void @__kmpc_for_static_fini(
139
140 // BLOCKS: [[G_PRIV_REF:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[RED_LIST]], i64 0, i64 0
141 // BLOCKS: [[BITCAST:%.+]] = bitcast double* [[G_PRIVATE_ADDR]] to i8*
142 // BLOCKS: store i8* [[BITCAST]], i8** [[G_PRIV_REF]],
143 // BLOCKS: call i32 @__kmpc_reduce(
144 // BLOCKS: switch i32 %{{.+}}, label %[[REDUCTION_DONE:.+]] [
145 // BLOCKS: i32 1, label %[[CASE1:.+]]
146 // BLOCKS: i32 2, label %[[CASE2:.+]]
147 // BLOCKS: [[CASE1]]
148 // BLOCKS: [[G_VAL:%.+]] = load double, double* [[G]]
149 // BLOCKS: [[G_PRIV_VAL:%.+]] = load double, double* [[G_PRIVATE_ADDR]]
150 // BLOCKS: [[ADD:%.+]] = fadd double [[G_VAL]], [[G_PRIV_VAL]]
151 // BLOCKS: store double [[ADD]], double* [[G]]
152 // BLOCKS: call void @__kmpc_end_reduce(
153 // BLOCKS: br label %[[REDUCTION_DONE]]
154 // BLOCKS: [[CASE2]]
155 // BLOCKS: [[G_PRIV_VAL:%.+]] = load double, double* [[G_PRIVATE_ADDR]]
156 // BLOCKS: fadd double
157 // BLOCKS: cmpxchg i64*
158 // BLOCKS: call void @__kmpc_end_reduce(
159 // BLOCKS: br label %[[REDUCTION_DONE]]
160 // BLOCKS: [[REDUCTION_DONE]]
161 // BLOCKS: ret void
162 #pragma omp section
163 ^{
164 // BLOCKS: define {{.+}} void {{@.+}}(i8*
165 g = 2;
166 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
167 // BLOCKS: store double 2.0{{.+}}, double*
168 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
169 // BLOCKS: ret
170 }();
171 }
172 }();
173 return 0;
174 #else
175 S<float> test;
176 float t_var = 0, t_var1;
177 int vec[] = {1, 2};
178 S<float> s_arr[] = {1, 2};
179 S<float> var(3), var1;
180 #pragma omp parallel
181 #pragma omp sections reduction(+:t_var) reduction(&:var) reduction(&& : var1) reduction(min: t_var1)
182 {
183 {
184 vec[0] = t_var;
185 s_arr[0] = var;
186 vec[1] = t_var1;
187 s_arr[1] = var1;
188 }
189 }
190 return tmain<int>();
191 #endif
192 }
193
194 // CHECK: define {{.*}}i{{[0-9]+}} @main()
195 // CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]],
196 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* {{[^,]*}} [[TEST]])
197 // 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
198 // CHECK: = call {{.*}}i{{.+}} [[TMAIN_INT:@.+]]()
199 // CHECK: call {{.*}} [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
200 // CHECK: ret
201 //
202 // CHECK: define internal void [[MAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}},
203 // CHECK: alloca float,
204 // CHECK: alloca [[S_FLOAT_TY]],
205 // CHECK: alloca [[S_FLOAT_TY]],
206 // CHECK: alloca float,
207
208 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
209
210 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
211 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
212
213 // CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
214 // CHECK-NOT: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
215
216 // CHECK: call void @__kmpc_for_static_init_4(
217 // CHECK: call void @__kmpc_for_static_fini(
218
219 // CHECK: call void @__kmpc_barrier(
220
221 // CHECK: ret void
222
223 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
224 // CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
225 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* {{[^,]*}} [[TEST]])
226 // 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
227 // CHECK: call {{.*}} [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
228 // CHECK: ret
229 //
230 // CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}},
231 // CHECK: alloca i{{[0-9]+}},
232 // CHECK: alloca i{{[0-9]+}},
233 // CHECK: alloca i{{[0-9]+}},
234 // CHECK: alloca i{{[0-9]+}},
235 // CHECK: alloca i{{[0-9]+}},
236 // CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
237 // CHECK: [[VAR_PRIV:%.+]] = alloca [[S_INT_TY]],
238 // CHECK: [[VAR1_PRIV:%.+]] = alloca [[S_INT_TY]],
239 // CHECK: [[T_VAR1_PRIV:%.+]] = alloca i{{[0-9]+}},
240
241 // Reduction list for runtime.
242 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
243
244 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
245
246 // CHECK: [[T_VAR_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
247 // CHECK: [[VAR_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
248 // CHECK: [[VAR1_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
249 // CHECK: [[T_VAR1_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
250
251 // For + reduction operation initial value of private variable is 0.
252 // CHECK: store i{{[0-9]+}} 0, i{{[0-9]+}}* [[T_VAR_PRIV]],
253
254 // For & reduction operation initial value of private variable is ones in all bits.
255 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* {{[^,]*}} [[VAR_PRIV]])
256
257 // For && reduction operation initial value of private variable is 1.0.
258 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* {{[^,]*}} [[VAR1_PRIV]])
259
260 // For min reduction operation initial value of private variable is largest repesentable value.
261 // CHECK: store i{{[0-9]+}} 2147483647, i{{[0-9]+}}* [[T_VAR1_PRIV]],
262
263 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
264 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
265 // CHECK: call void @__kmpc_for_static_init_4(
266 // Skip checks for internal operations.
267 // CHECK: call void @__kmpc_for_static_fini(
268
269 // void *RedList[<n>] = {<ReductionVars>[0], ..., <ReductionVars>[<n>-1]};
270
271 // CHECK: [[T_VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 0
272 // CHECK: [[BITCAST:%.+]] = bitcast i{{[0-9]+}}* [[T_VAR_PRIV]] to i8*
273 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR_PRIV_REF]],
274 // CHECK: [[VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 1
275 // CHECK: [[BITCAST:%.+]] = bitcast [[S_INT_TY]]* [[VAR_PRIV]] to i8*
276 // CHECK: store i8* [[BITCAST]], i8** [[VAR_PRIV_REF]],
277 // CHECK: [[VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 2
278 // CHECK: [[BITCAST:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_PRIV]] to i8*
279 // CHECK: store i8* [[BITCAST]], i8** [[VAR1_PRIV_REF]],
280 // CHECK: [[T_VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 3
281 // CHECK: [[BITCAST:%.+]] = bitcast i{{[0-9]+}}* [[T_VAR1_PRIV]] to i8*
282 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR1_PRIV_REF]],
283
284 // res = __kmpc_reduce_nowait(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>);
285
286 // CHECK: [[BITCAST:%.+]] = bitcast [4 x i8*]* [[RED_LIST]] to i8*
287 // 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]])
288
289 // switch(res)
290 // CHECK: switch i32 [[RES]], label %[[RED_DONE:.+]] [
291 // CHECK: i32 1, label %[[CASE1:.+]]
292 // CHECK: i32 2, label %[[CASE2:.+]]
293 // CHECK: ]
294
295 // case 1:
296 // t_var += t_var_reduction;
297 // CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_REF]],
298 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]],
299 // CHECK: [[UP:%.+]] = add nsw i{{[0-9]+}} [[T_VAR_VAL]], [[T_VAR_PRIV_VAL]]
300 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR_REF]],
301
302 // var = var.operator &(var_reduction);
303 // CHECK: [[UP:%.+]] = call nonnull align 4 dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR_REF]], [[S_INT_TY]]* nonnull align 4 dereferenceable(4) [[VAR_PRIV]])
304 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_REF]] to i8*
305 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
306 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[BC1]], i8* align 4 [[BC2]], i64 4, i1 false)
307
308 // var1 = var1.operator &&(var1_reduction);
309 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR1_REF]])
310 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
311 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
312 // CHECK: [[TRUE]]
313 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR1_PRIV]])
314 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
315 // CHECK: br label %[[END2]]
316 // CHECK: [[END2]]
317 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
318 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
319 // CHECK: call void @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[COND_LVALUE:%.+]], i32 [[CONV]])
320 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_REF]] to i8*
321 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
322 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[BC1]], i8* align 4 [[BC2]], i64 4, i1 false)
323
324 // t_var1 = min(t_var1, t_var1_reduction);
325 // CHECK: [[T_VAR1_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_REF]],
326 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_PRIV]],
327 // CHECK: [[CMP:%.+]] = icmp slt i{{[0-9]+}} [[T_VAR1_VAL]], [[T_VAR1_PRIV_VAL]]
328 // CHECK: br i1 [[CMP]]
329 // CHECK: [[UP:%.+]] = phi i32
330 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR1_REF]],
331
332 // __kmpc_end_reduce_nowait(<loc>, <gtid>, &<lock>);
333 // CHECK: call void @__kmpc_end_reduce_nowait(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], [8 x i32]* [[REDUCTION_LOCK]])
334
335 // break;
336 // CHECK: br label %[[RED_DONE]]
337
338 // case 2:
339 // t_var += t_var_reduction;
340 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]]
341 // CHECK: atomicrmw add i32* [[T_VAR_REF]], i32 [[T_VAR_PRIV_VAL]] monotonic
342
343 // var = var.operator &(var_reduction);
344 // CHECK: call void @__kmpc_critical(
345 // CHECK: [[UP:%.+]] = call nonnull align 4 dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR_REF]], [[S_INT_TY]]* nonnull align 4 dereferenceable(4) [[VAR_PRIV]])
346 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_REF]] to i8*
347 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
348 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[BC1]], i8* align 4 [[BC2]], i64 4, i1 false)
349 // CHECK: call void @__kmpc_end_critical(
350
351 // var1 = var1.operator &&(var1_reduction);
352 // CHECK: call void @__kmpc_critical(
353 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR1_REF]])
354 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
355 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
356 // CHECK: [[TRUE]]
357 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR1_PRIV]])
358 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
359 // CHECK: br label %[[END2]]
360 // CHECK: [[END2]]
361 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
362 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
363 // CHECK: call void @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[COND_LVALUE:%.+]], i32 [[CONV]])
364 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_REF]] to i8*
365 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
366 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[BC1]], i8* align 4 [[BC2]], i64 4, i1 false)
367 // CHECK: call void @__kmpc_end_critical(
368
369 // t_var1 = min(t_var1, t_var1_reduction);
370 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_PRIV]]
371 // CHECK: atomicrmw min i32* [[T_VAR1_REF]], i32 [[T_VAR1_PRIV_VAL]] monotonic
372
373 // break;
374 // CHECK: br label %[[RED_DONE]]
375 // CHECK: [[RED_DONE]]
376 // CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]* {{[^,]*}} [[VAR_PRIV]])
377 // CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]*
378 // CHECK: ret void
379
380 // void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
381 // *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
382 // ...
383 // *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
384 // *(Type<n>-1*)rhs[<n>-1]);
385 // }
386 // CHECK: define internal void [[REDUCTION_FUNC]](i8* %0, i8* %1)
387 // t_var_lhs = (i{{[0-9]+}}*)lhs[0];
388 // CHECK: [[T_VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS:%.+]], i64 0, i64 0
389 // CHECK: [[T_VAR_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR_RHS_REF]],
390 // CHECK: [[T_VAR_RHS:%.+]] = bitcast i8* [[T_VAR_RHS_VOID]] to i{{[0-9]+}}*
391 // t_var_rhs = (i{{[0-9]+}}*)rhs[0];
392 // CHECK: [[T_VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS:%.+]], i64 0, i64 0
393 // CHECK: [[T_VAR_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR_LHS_REF]],
394 // CHECK: [[T_VAR_LHS:%.+]] = bitcast i8* [[T_VAR_LHS_VOID]] to i{{[0-9]+}}*
395
396 // var_lhs = (S<i{{[0-9]+}}>*)lhs[1];
397 // CHECK: [[VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 1
398 // CHECK: [[VAR_RHS_VOID:%.+]] = load i8*, i8** [[VAR_RHS_REF]],
399 // CHECK: [[VAR_RHS:%.+]] = bitcast i8* [[VAR_RHS_VOID]] to [[S_INT_TY]]*
400 // var_rhs = (S<i{{[0-9]+}}>*)rhs[1];
401 // CHECK: [[VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 1
402 // CHECK: [[VAR_LHS_VOID:%.+]] = load i8*, i8** [[VAR_LHS_REF]],
403 // CHECK: [[VAR_LHS:%.+]] = bitcast i8* [[VAR_LHS_VOID]] to [[S_INT_TY]]*
404
405 // var1_lhs = (S<i{{[0-9]+}}>*)lhs[2];
406 // CHECK: [[VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 2
407 // CHECK: [[VAR1_RHS_VOID:%.+]] = load i8*, i8** [[VAR1_RHS_REF]],
408 // CHECK: [[VAR1_RHS:%.+]] = bitcast i8* [[VAR1_RHS_VOID]] to [[S_INT_TY]]*
409 // var1_rhs = (S<i{{[0-9]+}}>*)rhs[2];
410 // CHECK: [[VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 2
411 // CHECK: [[VAR1_LHS_VOID:%.+]] = load i8*, i8** [[VAR1_LHS_REF]],
412 // CHECK: [[VAR1_LHS:%.+]] = bitcast i8* [[VAR1_LHS_VOID]] to [[S_INT_TY]]*
413
414 // t_var1_lhs = (i{{[0-9]+}}*)lhs[3];
415 // CHECK: [[T_VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 3
416 // CHECK: [[T_VAR1_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_RHS_REF]],
417 // CHECK: [[T_VAR1_RHS:%.+]] = bitcast i8* [[T_VAR1_RHS_VOID]] to i{{[0-9]+}}*
418 // t_var1_rhs = (i{{[0-9]+}}*)rhs[3];
419 // CHECK: [[T_VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 3
420 // CHECK: [[T_VAR1_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_LHS_REF]],
421 // CHECK: [[T_VAR1_LHS:%.+]] = bitcast i8* [[T_VAR1_LHS_VOID]] to i{{[0-9]+}}*
422
423 // t_var_lhs += t_var_rhs;
424 // CHECK: [[T_VAR_LHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_LHS]],
425 // CHECK: [[T_VAR_RHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_RHS]],
426 // CHECK: [[UP:%.+]] = add nsw i{{[0-9]+}} [[T_VAR_LHS_VAL]], [[T_VAR_RHS_VAL]]
427 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR_LHS]],
428
429 // var_lhs = var_lhs.operator &(var_rhs);
430 // CHECK: [[UP:%.+]] = call nonnull align 4 dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR_LHS]], [[S_INT_TY]]* nonnull align 4 dereferenceable(4) [[VAR_RHS]])
431 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_LHS]] to i8*
432 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
433 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[BC1]], i8* align 4 [[BC2]], i64 4, i1 false)
434
435 // var1_lhs = var1_lhs.operator &&(var1_rhs);
436 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR1_LHS]])
437 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
438 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
439 // CHECK: [[TRUE]]
440 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[VAR1_RHS]])
441 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
442 // CHECK: br label %[[END2]]
443 // CHECK: [[END2]]
444 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
445 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
446 // CHECK: call void @{{.+}}([[S_INT_TY]]* {{[^,]*}} [[COND_LVALUE:%.+]], i32 [[CONV]])
447 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_LHS]] to i8*
448 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
449 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 [[BC1]], i8* align 4 [[BC2]], i64 4, i1 false)
450
451 // t_var1_lhs = min(t_var1_lhs, t_var1_rhs);
452 // CHECK: [[T_VAR1_LHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_LHS]],
453 // CHECK: [[T_VAR1_RHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_RHS]],
454 // CHECK: [[CMP:%.+]] = icmp slt i{{[0-9]+}} [[T_VAR1_LHS_VAL]], [[T_VAR1_RHS_VAL]]
455 // CHECK: br i1 [[CMP]]
456 // CHECK: [[UP:%.+]] = phi i32
457 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR1_LHS]],
458 // CHECK: ret void
459
460 #endif
461
462