Home | History | Annotate | Download | only in OpenMP
      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 // REQUIRES: x86-registered-target
      7 // expected-no-diagnostics
      8 #ifndef HEADER
      9 #define HEADER
     10 
     11 volatile int g __attribute__((aligned(128))) = 1212;
     12 
     13 template <class T>
     14 struct S {
     15   T f;
     16   S(T a) : f(a + g) {}
     17   S() : f(g) {}
     18   operator T() { return T(); }
     19   S &operator&(const S &) { return *this; }
     20   ~S() {}
     21 };
     22 
     23 // CHECK-DAG: [[S_FLOAT_TY:%.+]] = type { float }
     24 // CHECK-DAG: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }
     25 // CHECK-DAG: [[REDUCTION_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 18, i32 0, i32 0, i8*
     26 // CHECK-DAG: [[REDUCTION_LOCK:@.+]] = common global [8 x i32] zeroinitializer
     27 
     28 template <typename T>
     29 T tmain() {
     30   T t;
     31   S<T> test;
     32   T t_var __attribute__((aligned(128))) = T(), t_var1 __attribute__((aligned(128)));
     33   T vec[] = {1, 2};
     34   S<T> s_arr[]  = {1, 2};
     35   S<T> var __attribute__((aligned(128))) (3), var1 __attribute__((aligned(128)));
     36 #pragma omp parallel reduction(+:t_var) reduction(&:var) reduction(&& : var1) reduction(min: t_var1)
     37   {
     38     vec[0] = t_var;
     39     s_arr[0] = var;
     40   }
     41   return T();
     42 }
     43 
     44 int main() {
     45 #ifdef LAMBDA
     46   // LAMBDA: [[G:@.+]] = global i{{[0-9]+}} 1212,
     47   // LAMBDA-LABEL: @main
     48   // LAMBDA: call void [[OUTER_LAMBDA:@.+]](
     49   [&]() {
     50   // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
     51   // LAMBDA: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 1, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* [[G]])
     52 #pragma omp parallel reduction(+:g)
     53   {
     54     // LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable(4) %{{.+}})
     55     // LAMBDA: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
     56 
     57     // Reduction list for runtime.
     58     // LAMBDA: [[RED_LIST:%.+]] = alloca [1 x i8*],
     59 
     60     // LAMBDA: [[G_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[G_REF_ADDR:%.+]]
     61     // LAMBDA: store i{{[0-9]+}} 0, i{{[0-9]+}}* [[G_PRIVATE_ADDR]], align 128
     62     g = 1;
     63     // LAMBDA: store i{{[0-9]+}} 1, i{{[0-9]+}}* [[G_PRIVATE_ADDR]], align 128
     64     // LAMBDA: [[G_PRIVATE_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
     65     // LAMBDA: store i{{[0-9]+}}* [[G_PRIVATE_ADDR]], i{{[0-9]+}}** [[G_PRIVATE_ADDR_REF]]
     66     // LAMBDA: call void [[INNER_LAMBDA:@.+]](%{{.+}}* [[ARG]])
     67 
     68     // LAMBDA: [[G_PRIV_REF:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[RED_LIST]], i64 0, i64 0
     69     // LAMBDA: [[BITCAST:%.+]] = bitcast i32* [[G_PRIVATE_ADDR]] to i8*
     70     // LAMBDA: store i8* [[BITCAST]], i8** [[G_PRIV_REF]],
     71     // LAMBDA: call i32 @__kmpc_reduce_nowait(
     72     // LAMBDA: switch i32 %{{.+}}, label %[[REDUCTION_DONE:.+]] [
     73     // LAMBDA: i32 1, label %[[CASE1:.+]]
     74     // LAMBDA: i32 2, label %[[CASE2:.+]]
     75     // LAMBDA: [[CASE1]]
     76     // LAMBDA: [[G_VAL:%.+]] = load i32, i32* [[G_REF]]
     77     // LAMBDA: [[G_PRIV_VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]]
     78     // LAMBDA: [[ADD:%.+]] = add nsw i32 [[G_VAL]], [[G_PRIV_VAL]]
     79     // LAMBDA: store i32 [[ADD]], i32* [[G_REF]]
     80     // LAMBDA: call void @__kmpc_end_reduce_nowait(
     81     // LAMBDA: br label %[[REDUCTION_DONE]]
     82     // LAMBDA: [[CASE2]]
     83     // LAMBDA: [[G_PRIV_VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]]
     84     // LAMBDA: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic
     85     // LAMBDA: br label %[[REDUCTION_DONE]]
     86     // LAMBDA: [[REDUCTION_DONE]]
     87     // LAMBDA: ret void
     88     [&]() {
     89       // LAMBDA: define {{.+}} void [[INNER_LAMBDA]](%{{.+}}* [[ARG_PTR:%.+]])
     90       // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
     91       g = 2;
     92       // LAMBDA: [[ARG_PTR:%.+]] = load %{{.+}}*, %{{.+}}** [[ARG_PTR_REF]]
     93       // LAMBDA: [[G_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
     94       // LAMBDA: [[G_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[G_PTR_REF]]
     95       // LAMBDA: store i{{[0-9]+}} 2, i{{[0-9]+}}* [[G_REF]]
     96     }();
     97   }
     98   }();
     99   return 0;
    100 #elif defined(BLOCKS)
    101   // BLOCKS: [[G:@.+]] = global i{{[0-9]+}} 1212,
    102   // BLOCKS-LABEL: @main
    103   // BLOCKS: call void {{%.+}}(i8
    104   ^{
    105   // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
    106   // BLOCKS: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 1, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* [[G]])
    107 #pragma omp parallel reduction(-:g)
    108   {
    109     // BLOCKS: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable(4) %{{.+}})
    110     // BLOCKS: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
    111 
    112     // Reduction list for runtime.
    113     // BLOCKS: [[RED_LIST:%.+]] = alloca [1 x i8*],
    114 
    115     // BLOCKS: [[G_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[G_REF_ADDR:%.+]]
    116     // BLOCKS: store i{{[0-9]+}} 0, i{{[0-9]+}}* [[G_PRIVATE_ADDR]], align 128
    117     g = 1;
    118     // BLOCKS: store i{{[0-9]+}} 1, i{{[0-9]+}}* [[G_PRIVATE_ADDR]], align 128
    119     // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
    120     // BLOCKS: i{{[0-9]+}}* [[G_PRIVATE_ADDR]]
    121     // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
    122     // BLOCKS: call void {{%.+}}(i8
    123 
    124     // BLOCKS: [[G_PRIV_REF:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[RED_LIST]], i64 0, i64 0
    125     // BLOCKS: [[BITCAST:%.+]] = bitcast i32* [[G_PRIVATE_ADDR]] to i8*
    126     // BLOCKS: store i8* [[BITCAST]], i8** [[G_PRIV_REF]],
    127     // BLOCKS: call i32 @__kmpc_reduce_nowait(
    128     // BLOCKS: switch i32 %{{.+}}, label %[[REDUCTION_DONE:.+]] [
    129     // BLOCKS: i32 1, label %[[CASE1:.+]]
    130     // BLOCKS: i32 2, label %[[CASE2:.+]]
    131     // BLOCKS: [[CASE1]]
    132     // BLOCKS: [[G_VAL:%.+]] = load i32, i32* [[G_REF]]
    133     // BLOCKS: [[G_PRIV_VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]]
    134     // BLOCKS: [[ADD:%.+]] = add nsw i32 [[G_VAL]], [[G_PRIV_VAL]]
    135     // BLOCKS: store i32 [[ADD]], i32* [[G_REF]]
    136     // BLOCKS: call void @__kmpc_end_reduce_nowait(
    137     // BLOCKS: br label %[[REDUCTION_DONE]]
    138     // BLOCKS: [[CASE2]]
    139     // BLOCKS: [[G_PRIV_VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]]
    140     // BLOCKS: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic
    141     // BLOCKS: br label %[[REDUCTION_DONE]]
    142     // BLOCKS: [[REDUCTION_DONE]]
    143     // BLOCKS: ret void
    144     ^{
    145       // BLOCKS: define {{.+}} void {{@.+}}(i8*
    146       g = 2;
    147       // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
    148       // BLOCKS: store i{{[0-9]+}} 2, i{{[0-9]+}}*
    149       // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
    150       // BLOCKS: ret
    151     }();
    152   }
    153   }();
    154   return 0;
    155 #else
    156   S<float> test;
    157   float t_var = 0, t_var1;
    158   int vec[] = {1, 2};
    159   S<float> s_arr[] = {1, 2};
    160   S<float> var(3), var1;
    161 #pragma omp parallel reduction(+:t_var) reduction(&:var) reduction(&& : var1) reduction(min: t_var1)
    162   {
    163     vec[0] = t_var;
    164     s_arr[0] = var;
    165   }
    166   if (var1)
    167 #pragma omp parallel reduction(+ : t_var) reduction(& : var) reduction(&& : var1) reduction(min : t_var1)
    168     while (1) {
    169       vec[0] = t_var;
    170       s_arr[0] = var;
    171     }
    172   return tmain<int>();
    173 #endif
    174 }
    175 
    176 // CHECK: define {{.*}}i{{[0-9]+}} @main()
    177 // CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]],
    178 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]])
    179 // 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]+}}*, [2 x i32]*, float*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]*, float*)* [[MAIN_MICROTASK:@.+]] to void
    180 // 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]+}}*, [2 x i32]*, float*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]*, float*)* [[MAIN_MICROTASK1:@.+]] to void
    181 // CHECK: = call {{.*}}i{{.+}} [[TMAIN_INT:@.+]]()
    182 // CHECK: call {{.*}} [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
    183 // CHECK: ret
    184 //
    185 // CHECK: define internal void [[MAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}},
    186 // CHECK: [[T_VAR_PRIV:%.+]] = alloca float,
    187 // CHECK: [[VAR_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
    188 // CHECK: [[VAR1_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
    189 // CHECK: [[T_VAR1_PRIV:%.+]] = alloca float,
    190 
    191 // Reduction list for runtime.
    192 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
    193 
    194 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
    195 
    196 // CHECK: [[T_VAR_REF:%.+]] = load float*, float** %
    197 // CHECK: [[VAR_REF:%.+]] = load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
    198 // CHECK: [[VAR1_REF:%.+]] = load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
    199 // CHECK: [[T_VAR1_REF:%.+]] = load float*, float** %
    200 
    201 // For + reduction operation initial value of private variable is 0.
    202 // CHECK: store float 0.0{{.+}}, float* [[T_VAR_PRIV]],
    203 
    204 // For & reduction operation initial value of private variable is ones in all bits.
    205 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
    206 
    207 // For && reduction operation initial value of private variable is 1.0.
    208 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[VAR1_PRIV]])
    209 
    210 // For min reduction operation initial value of private variable is largest repesentable value.
    211 // CHECK: store float 0x47EFFFFFE0000000, float* [[T_VAR1_PRIV]],
    212 
    213 // Skip checks for internal operations.
    214 
    215 // void *RedList[<n>] = {<ReductionVars>[0], ..., <ReductionVars>[<n>-1]};
    216 
    217 // CHECK: [[T_VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 0
    218 // CHECK: [[BITCAST:%.+]] = bitcast float* [[T_VAR_PRIV]] to i8*
    219 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR_PRIV_REF]],
    220 // CHECK: [[VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 1
    221 // CHECK: [[BITCAST:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR_PRIV]] to i8*
    222 // CHECK: store i8* [[BITCAST]], i8** [[VAR_PRIV_REF]],
    223 // CHECK: [[VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 2
    224 // CHECK: [[BITCAST:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR1_PRIV]] to i8*
    225 // CHECK: store i8* [[BITCAST]], i8** [[VAR1_PRIV_REF]],
    226 // CHECK: [[T_VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 3
    227 // CHECK: [[BITCAST:%.+]] = bitcast float* [[T_VAR1_PRIV]] to i8*
    228 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR1_PRIV_REF]],
    229 
    230 // res = __kmpc_reduce_nowait(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>);
    231 
    232 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
    233 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
    234 // CHECK: [[BITCAST:%.+]] = bitcast [4 x i8*]* [[RED_LIST]] to i8*
    235 // 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]])
    236 
    237 // switch(res)
    238 // CHECK: switch i32 [[RES]], label %[[RED_DONE:.+]] [
    239 // CHECK: i32 1, label %[[CASE1:.+]]
    240 // CHECK: i32 2, label %[[CASE2:.+]]
    241 // CHECK: ]
    242 
    243 // case 1:
    244 // t_var += t_var_reduction;
    245 // CHECK: [[T_VAR_VAL:%.+]] = load float, float* [[T_VAR_REF]],
    246 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load float, float* [[T_VAR_PRIV]],
    247 // CHECK: [[UP:%.+]] = fadd float [[T_VAR_VAL]], [[T_VAR_PRIV_VAL]]
    248 // CHECK: store float [[UP]], float* [[T_VAR_REF]],
    249 
    250 // var = var.operator &(var_reduction);
    251 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @{{.+}}([[S_FLOAT_TY]]* [[VAR_REF]], [[S_FLOAT_TY]]* dereferenceable(4) [[VAR_PRIV]])
    252 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR_REF]] to i8*
    253 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[UP]] to i8*
    254 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    255 
    256 // var1 = var1.operator &&(var1_reduction);
    257 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_REF]])
    258 // CHECK: [[VAR1_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
    259 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
    260 // CHECK: [[TRUE]]
    261 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_PRIV]])
    262 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
    263 // CHECK: br label %[[END2]]
    264 // CHECK: [[END2]]
    265 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
    266 // CHECK: [[CONV:%.+]] = uitofp i1 [[COND_LVALUE]] to float
    267 // CHECK:  call void @{{.+}}([[S_FLOAT_TY]]* [[COND_LVALUE:%.+]], float [[CONV]])
    268 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR1_REF]] to i8*
    269 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[COND_LVALUE]] to i8*
    270 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    271 
    272 // t_var1 = min(t_var1, t_var1_reduction);
    273 // CHECK: [[T_VAR1_VAL:%.+]] = load float, float* [[T_VAR1_REF]],
    274 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load float, float* [[T_VAR1_PRIV]],
    275 // CHECK: [[CMP:%.+]] = fcmp olt float [[T_VAR1_VAL]], [[T_VAR1_PRIV_VAL]]
    276 // CHECK: br i1 [[CMP]]
    277 // CHECK: [[UP:%.+]] = phi float
    278 // CHECK: store float [[UP]], float* [[T_VAR1_REF]],
    279 
    280 // __kmpc_end_reduce_nowait(<loc>, <gtid>, &<lock>);
    281 // CHECK: call void @__kmpc_end_reduce_nowait(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], [8 x i32]* [[REDUCTION_LOCK]])
    282 
    283 // break;
    284 // CHECK: br label %[[RED_DONE]]
    285 
    286 // case 2:
    287 // t_var += t_var_reduction;
    288 // CHECK: load float, float* [[T_VAR_PRIV]]
    289 // CHECK: [[T_VAR_REF_INT:%.+]] = bitcast float* [[T_VAR_REF]] to i32*
    290 // CHECK: [[OLD1:%.+]] = load atomic i32, i32* [[T_VAR_REF_INT]] monotonic,
    291 // CHECK: br label %[[CONT:.+]]
    292 // CHECK: [[CONT]]
    293 // CHECK: [[ORIG_OLD_INT:%.+]] = phi i32 [ [[OLD1]], %{{.+}} ], [ [[OLD2:%.+]], %[[CONT]] ]
    294 // CHECK: fadd float
    295 // CHECK: [[UP_INT:%.+]] = load i32
    296 // CHECK: [[T_VAR_REF_INT:%.+]] = bitcast float* [[T_VAR_REF]] to i32*
    297 // CHECK: [[RES:%.+]] = cmpxchg i32* [[T_VAR_REF_INT]], i32 [[ORIG_OLD_INT]], i32 [[UP_INT]] monotonic monotonic
    298 // CHECK: [[OLD2:%.+]] = extractvalue { i32, i1 } [[RES]], 0
    299 // CHECK: [[SUCCESS_FAIL:%.+]] = extractvalue { i32, i1 } [[RES]], 1
    300 // CHECK: br i1 [[SUCCESS_FAIL]], label %[[ATOMIC_DONE:.+]], label %[[CONT]]
    301 // CHECK: [[ATOMIC_DONE]]
    302 
    303 // var = var.operator &(var_reduction);
    304 // CHECK: call void @__kmpc_critical(
    305 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @{{.+}}([[S_FLOAT_TY]]* [[VAR_REF]], [[S_FLOAT_TY]]* dereferenceable(4) [[VAR_PRIV]])
    306 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR_REF]] to i8*
    307 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[UP]] to i8*
    308 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    309 // CHECK: call void @__kmpc_end_critical(
    310 
    311 // var1 = var1.operator &&(var1_reduction);
    312 // CHECK: call void @__kmpc_critical(
    313 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_REF]])
    314 // CHECK: [[VAR1_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
    315 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
    316 // CHECK: [[TRUE]]
    317 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_PRIV]])
    318 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
    319 // CHECK: br label %[[END2]]
    320 // CHECK: [[END2]]
    321 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
    322 // CHECK: [[CONV:%.+]] = uitofp i1 [[COND_LVALUE]] to float
    323 // CHECK:  call void @{{.+}}([[S_FLOAT_TY]]* [[COND_LVALUE:%.+]], float [[CONV]])
    324 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR1_REF]] to i8*
    325 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[COND_LVALUE]] to i8*
    326 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    327 // CHECK: call void @__kmpc_end_critical(
    328 
    329 // t_var1 = min(t_var1, t_var1_reduction);
    330 // CHECK: load float, float* [[T_VAR1_PRIV]]
    331 // CHECK: [[T_VAR1_REF_INT:%.+]] = bitcast float* [[T_VAR1_REF]] to i32*
    332 // CHECK: [[OLD1:%.+]] = load atomic i32, i32* [[T_VAR1_REF_INT]] monotonic,
    333 // CHECK: br label %[[CONT:.+]]
    334 // CHECK: [[CONT]]
    335 // CHECK: [[ORIG_OLD_INT:%.+]] = phi i32 [ [[OLD1]], %{{.+}} ], [ [[OLD2:%.+]], %{{.+}} ]
    336 // CHECK: [[CMP:%.+]] = fcmp olt float
    337 // CHECK: br i1 [[CMP]]
    338 // CHECK: [[UP:%.+]] = phi float
    339 // CHECK: [[UP_INT:%.+]] = load i32
    340 // CHECK: [[T_VAR1_REF_INT:%.+]] = bitcast float* [[T_VAR1_REF]] to i32*
    341 // CHECK: [[RES:%.+]] = cmpxchg i32* [[T_VAR1_REF_INT]], i32 [[ORIG_OLD_INT]], i32 [[UP_INT]] monotonic monotonic
    342 // CHECK: [[OLD2:%.+]] = extractvalue { i32, i1 } [[RES]], 0
    343 // CHECK: [[SUCCESS_FAIL:%.+]] = extractvalue { i32, i1 } [[RES]], 1
    344 // CHECK: br i1 [[SUCCESS_FAIL]], label %[[ATOMIC_DONE:.+]], label %[[CONT]]
    345 // CHECK: [[ATOMIC_DONE]]
    346 
    347 // break;
    348 // CHECK: br label %[[RED_DONE]]
    349 // CHECK: [[RED_DONE]]
    350 
    351 // CHECK-DAG: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
    352 // CHECK-DAG: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
    353 // CHECK: ret void
    354 
    355 // void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
    356 //  *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
    357 //  ...
    358 //  *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
    359 //  *(Type<n>-1*)rhs[<n>-1]);
    360 // }
    361 // CHECK: define internal void [[REDUCTION_FUNC]](i8*, i8*)
    362 // t_var_lhs = (float*)lhs[0];
    363 // CHECK: [[T_VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS:%.+]], i64 0, i64 0
    364 // CHECK: [[T_VAR_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR_RHS_REF]],
    365 // CHECK: [[T_VAR_RHS:%.+]] = bitcast i8* [[T_VAR_RHS_VOID]] to float*
    366 // t_var_rhs = (float*)rhs[0];
    367 // CHECK: [[T_VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS:%.+]], i64 0, i64 0
    368 // CHECK: [[T_VAR_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR_LHS_REF]],
    369 // CHECK: [[T_VAR_LHS:%.+]] = bitcast i8* [[T_VAR_LHS_VOID]] to float*
    370 
    371 // var_lhs = (S<float>*)lhs[1];
    372 // CHECK: [[VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 1
    373 // CHECK: [[VAR_RHS_VOID:%.+]] = load i8*, i8** [[VAR_RHS_REF]],
    374 // CHECK: [[VAR_RHS:%.+]] = bitcast i8* [[VAR_RHS_VOID]] to [[S_FLOAT_TY]]*
    375 // var_rhs = (S<float>*)rhs[1];
    376 // CHECK: [[VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 1
    377 // CHECK: [[VAR_LHS_VOID:%.+]] = load i8*, i8** [[VAR_LHS_REF]],
    378 // CHECK: [[VAR_LHS:%.+]] = bitcast i8* [[VAR_LHS_VOID]] to [[S_FLOAT_TY]]*
    379 
    380 // var1_lhs = (S<float>*)lhs[2];
    381 // CHECK: [[VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 2
    382 // CHECK: [[VAR1_RHS_VOID:%.+]] = load i8*, i8** [[VAR1_RHS_REF]],
    383 // CHECK: [[VAR1_RHS:%.+]] = bitcast i8* [[VAR1_RHS_VOID]] to [[S_FLOAT_TY]]*
    384 // var1_rhs = (S<float>*)rhs[2];
    385 // CHECK: [[VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 2
    386 // CHECK: [[VAR1_LHS_VOID:%.+]] = load i8*, i8** [[VAR1_LHS_REF]],
    387 // CHECK: [[VAR1_LHS:%.+]] = bitcast i8* [[VAR1_LHS_VOID]] to [[S_FLOAT_TY]]*
    388 
    389 // t_var1_lhs = (float*)lhs[3];
    390 // CHECK: [[T_VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 3
    391 // CHECK: [[T_VAR1_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_RHS_REF]],
    392 // CHECK: [[T_VAR1_RHS:%.+]] = bitcast i8* [[T_VAR1_RHS_VOID]] to float*
    393 // t_var1_rhs = (float*)rhs[3];
    394 // CHECK: [[T_VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 3
    395 // CHECK: [[T_VAR1_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_LHS_REF]],
    396 // CHECK: [[T_VAR1_LHS:%.+]] = bitcast i8* [[T_VAR1_LHS_VOID]] to float*
    397 
    398 // t_var_lhs += t_var_rhs;
    399 // CHECK: [[T_VAR_LHS_VAL:%.+]] = load float, float* [[T_VAR_LHS]],
    400 // CHECK: [[T_VAR_RHS_VAL:%.+]] = load float, float* [[T_VAR_RHS]],
    401 // CHECK: [[UP:%.+]] = fadd float [[T_VAR_LHS_VAL]], [[T_VAR_RHS_VAL]]
    402 // CHECK: store float [[UP]], float* [[T_VAR_LHS]],
    403 
    404 // var_lhs = var_lhs.operator &(var_rhs);
    405 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_FLOAT_TY]]* @{{.+}}([[S_FLOAT_TY]]* [[VAR_LHS]], [[S_FLOAT_TY]]* dereferenceable(4) [[VAR_RHS]])
    406 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR_LHS]] to i8*
    407 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[UP]] to i8*
    408 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    409 
    410 // var1_lhs = var1_lhs.operator &&(var1_rhs);
    411 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_LHS]])
    412 // CHECK: [[VAR1_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
    413 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
    414 // CHECK: [[TRUE]]
    415 // CHECK: [[TO_FLOAT:%.+]] = call float @{{.+}}([[S_FLOAT_TY]]* [[VAR1_RHS]])
    416 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = fcmp une float [[TO_FLOAT]], 0.0
    417 // CHECK: br label %[[END2]]
    418 // CHECK: [[END2]]
    419 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
    420 // CHECK: [[CONV:%.+]] = uitofp i1 [[COND_LVALUE]] to float
    421 // CHECK:  call void @{{.+}}([[S_FLOAT_TY]]* [[COND_LVALUE:%.+]], float [[CONV]])
    422 // CHECK: [[BC1:%.+]] = bitcast [[S_FLOAT_TY]]* [[VAR1_LHS]] to i8*
    423 // CHECK: [[BC2:%.+]] = bitcast [[S_FLOAT_TY]]* [[COND_LVALUE]] to i8*
    424 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    425 
    426 // t_var1_lhs = min(t_var1_lhs, t_var1_rhs);
    427 // CHECK: [[T_VAR1_LHS_VAL:%.+]] = load float, float* [[T_VAR1_LHS]],
    428 // CHECK: [[T_VAR1_RHS_VAL:%.+]] = load float, float* [[T_VAR1_RHS]],
    429 // CHECK: [[CMP:%.+]] = fcmp olt float [[T_VAR1_LHS_VAL]], [[T_VAR1_RHS_VAL]]
    430 // CHECK: br i1 [[CMP]]
    431 // CHECK: [[UP:%.+]] = phi float
    432 // CHECK: store float [[UP]], float* [[T_VAR1_LHS]],
    433 // CHECK: ret void
    434 
    435 // CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}},
    436 // CHECK: [[T_VAR_PRIV:%.+]] = alloca float,
    437 // CHECK: [[VAR_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
    438 // CHECK: [[VAR1_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
    439 // CHECK: [[T_VAR1_PRIV:%.+]] = alloca float,
    440 
    441 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
    442 
    443 // CHECK: [[T_VAR_REF:%.+]] = load float*, float** %
    444 // CHECK: [[VAR_REF:%.+]] = load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
    445 // CHECK: [[VAR1_REF:%.+]] = load [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]** %
    446 // CHECK: [[T_VAR1_REF:%.+]] = load float*, float** %
    447 
    448 // For + reduction operation initial value of private variable is 0.
    449 // CHECK: store float 0.0{{.+}}, float* [[T_VAR_PRIV]],
    450 
    451 // For & reduction operation initial value of private variable is ones in all bits.
    452 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
    453 
    454 // For && reduction operation initial value of private variable is 1.0.
    455 // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[VAR1_PRIV]])
    456 
    457 // For min reduction operation initial value of private variable is largest repesentable value.
    458 // CHECK: store float 0x47EFFFFFE0000000, float* [[T_VAR1_PRIV]],
    459 
    460 // CHECK-NOT: call i32 @__kmpc_reduce
    461 
    462 // CHECK: ret void
    463 
    464 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
    465 // CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
    466 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* [[TEST]])
    467 // 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]+}}*, [2 x i32]*, i32*, [2 x [[S_INT_TY]]]*, [[S_INT_TY]]*, [[S_INT_TY]]*, i32*)* [[TMAIN_MICROTASK:@.+]] to void
    468 // CHECK: call {{.*}} [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
    469 // CHECK: ret
    470 //
    471 // CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}},
    472 // CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}}, align 128
    473 // CHECK: [[VAR_PRIV:%.+]] = alloca [[S_INT_TY]], align 128
    474 // CHECK: [[VAR1_PRIV:%.+]] = alloca [[S_INT_TY]], align 128
    475 // CHECK: [[T_VAR1_PRIV:%.+]] = alloca i{{[0-9]+}}, align 128
    476 
    477 // Reduction list for runtime.
    478 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
    479 
    480 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
    481 
    482 // CHECK: [[T_VAR_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
    483 // CHECK: [[VAR_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
    484 // CHECK: [[VAR1_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
    485 // CHECK: [[T_VAR1_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
    486 
    487 // For + reduction operation initial value of private variable is 0.
    488 // CHECK: store i{{[0-9]+}} 0, i{{[0-9]+}}* [[T_VAR_PRIV]],
    489 
    490 // For & reduction operation initial value of private variable is ones in all bits.
    491 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* [[VAR_PRIV]])
    492 
    493 // For && reduction operation initial value of private variable is 1.0.
    494 // CHECK: call {{.*}} [[S_INT_TY_CONSTR:@.+]]([[S_INT_TY]]* [[VAR1_PRIV]])
    495 
    496 // For min reduction operation initial value of private variable is largest repesentable value.
    497 // CHECK: store i{{[0-9]+}} 2147483647, i{{[0-9]+}}* [[T_VAR1_PRIV]],
    498 
    499 // Skip checks for internal operations.
    500 
    501 // void *RedList[<n>] = {<ReductionVars>[0], ..., <ReductionVars>[<n>-1]};
    502 
    503 // CHECK: [[T_VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 0
    504 // CHECK: [[BITCAST:%.+]] = bitcast i{{[0-9]+}}* [[T_VAR_PRIV]] to i8*
    505 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR_PRIV_REF]],
    506 // CHECK: [[VAR_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 1
    507 // CHECK: [[BITCAST:%.+]] = bitcast [[S_INT_TY]]* [[VAR_PRIV]] to i8*
    508 // CHECK: store i8* [[BITCAST]], i8** [[VAR_PRIV_REF]],
    509 // CHECK: [[VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 2
    510 // CHECK: [[BITCAST:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_PRIV]] to i8*
    511 // CHECK: store i8* [[BITCAST]], i8** [[VAR1_PRIV_REF]],
    512 // CHECK: [[T_VAR1_PRIV_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST]], i64 0, i64 3
    513 // CHECK: [[BITCAST:%.+]] = bitcast i{{[0-9]+}}* [[T_VAR1_PRIV]] to i8*
    514 // CHECK: store i8* [[BITCAST]], i8** [[T_VAR1_PRIV_REF]],
    515 
    516 // res = __kmpc_reduce_nowait(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>);
    517 
    518 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
    519 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
    520 // CHECK: [[BITCAST:%.+]] = bitcast [4 x i8*]* [[RED_LIST]] to i8*
    521 // 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]])
    522 
    523 // switch(res)
    524 // CHECK: switch i32 [[RES]], label %[[RED_DONE:.+]] [
    525 // CHECK: i32 1, label %[[CASE1:.+]]
    526 // CHECK: i32 2, label %[[CASE2:.+]]
    527 // CHECK: ]
    528 
    529 // case 1:
    530 // t_var += t_var_reduction;
    531 // CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_REF]],
    532 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]],
    533 // CHECK: [[UP:%.+]] = add nsw i{{[0-9]+}} [[T_VAR_VAL]], [[T_VAR_PRIV_VAL]]
    534 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR_REF]],
    535 
    536 // var = var.operator &(var_reduction);
    537 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* [[VAR_REF]], [[S_INT_TY]]* dereferenceable(4) [[VAR_PRIV]])
    538 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_REF]] to i8*
    539 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
    540 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    541 
    542 // var1 = var1.operator &&(var1_reduction);
    543 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_REF]])
    544 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
    545 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
    546 // CHECK: [[TRUE]]
    547 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_PRIV]])
    548 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
    549 // CHECK: [[END2]]
    550 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
    551 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
    552 // CHECK:  call void @{{.+}}([[S_INT_TY]]* [[COND_LVALUE:%.+]], i32 [[CONV]])
    553 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_REF]] to i8*
    554 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
    555 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    556 
    557 // t_var1 = min(t_var1, t_var1_reduction);
    558 // CHECK: [[T_VAR1_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_REF]],
    559 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_PRIV]],
    560 // CHECK: [[CMP:%.+]] = icmp slt i{{[0-9]+}} [[T_VAR1_VAL]], [[T_VAR1_PRIV_VAL]]
    561 // CHECK: br i1 [[CMP]]
    562 // CHECK: [[UP:%.+]] = phi i32
    563 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR1_REF]],
    564 
    565 // __kmpc_end_reduce_nowait(<loc>, <gtid>, &<lock>);
    566 // CHECK: call void @__kmpc_end_reduce_nowait(%{{.+}}* [[REDUCTION_LOC]], i32 [[GTID]], [8 x i32]* [[REDUCTION_LOCK]])
    567 
    568 // break;
    569 // CHECK: br label %[[RED_DONE]]
    570 
    571 // case 2:
    572 // t_var += t_var_reduction;
    573 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]]
    574 // CHECK: atomicrmw add i32* [[T_VAR_REF]], i32 [[T_VAR_PRIV_VAL]] monotonic
    575 
    576 // var = var.operator &(var_reduction);
    577 // CHECK: call void @__kmpc_critical(
    578 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* [[VAR_REF]], [[S_INT_TY]]* dereferenceable(4) [[VAR_PRIV]])
    579 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_REF]] to i8*
    580 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
    581 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    582 // CHECK: call void @__kmpc_end_critical(
    583 
    584 // var1 = var1.operator &&(var1_reduction);
    585 // CHECK: call void @__kmpc_critical(
    586 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_REF]])
    587 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
    588 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
    589 // CHECK: [[TRUE]]
    590 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_PRIV]])
    591 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
    592 // CHECK: br label %[[END2]]
    593 // CHECK: [[END2]]
    594 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
    595 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
    596 // CHECK:  call void @{{.+}}([[S_INT_TY]]* [[COND_LVALUE:%.+]], i32 [[CONV]])
    597 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_REF]] to i8*
    598 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
    599 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    600 // CHECK: call void @__kmpc_end_critical(
    601 
    602 // t_var1 = min(t_var1, t_var1_reduction);
    603 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_PRIV]]
    604 // CHECK: atomicrmw min i32* [[T_VAR1_REF]], i32 [[T_VAR1_PRIV_VAL]] monotonic
    605 
    606 // break;
    607 // CHECK: br label %[[RED_DONE]]
    608 // CHECK: [[RED_DONE]]
    609 
    610 // CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]* [[VAR_PRIV]])
    611 // CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]*
    612 // CHECK: ret void
    613 
    614 // void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
    615 //  *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]);
    616 //  ...
    617 //  *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1],
    618 //  *(Type<n>-1*)rhs[<n>-1]);
    619 // }
    620 // CHECK: define internal void [[REDUCTION_FUNC]](i8*, i8*)
    621 // t_var_lhs = (i{{[0-9]+}}*)lhs[0];
    622 // CHECK: [[T_VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS:%.+]], i64 0, i64 0
    623 // CHECK: [[T_VAR_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR_RHS_REF]],
    624 // CHECK: [[T_VAR_RHS:%.+]] = bitcast i8* [[T_VAR_RHS_VOID]] to i{{[0-9]+}}*
    625 // t_var_rhs = (i{{[0-9]+}}*)rhs[0];
    626 // CHECK: [[T_VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS:%.+]], i64 0, i64 0
    627 // CHECK: [[T_VAR_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR_LHS_REF]],
    628 // CHECK: [[T_VAR_LHS:%.+]] = bitcast i8* [[T_VAR_LHS_VOID]] to i{{[0-9]+}}*
    629 
    630 // var_lhs = (S<i{{[0-9]+}}>*)lhs[1];
    631 // CHECK: [[VAR_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 1
    632 // CHECK: [[VAR_RHS_VOID:%.+]] = load i8*, i8** [[VAR_RHS_REF]],
    633 // CHECK: [[VAR_RHS:%.+]] = bitcast i8* [[VAR_RHS_VOID]] to [[S_INT_TY]]*
    634 // var_rhs = (S<i{{[0-9]+}}>*)rhs[1];
    635 // CHECK: [[VAR_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 1
    636 // CHECK: [[VAR_LHS_VOID:%.+]] = load i8*, i8** [[VAR_LHS_REF]],
    637 // CHECK: [[VAR_LHS:%.+]] = bitcast i8* [[VAR_LHS_VOID]] to [[S_INT_TY]]*
    638 
    639 // var1_lhs = (S<i{{[0-9]+}}>*)lhs[2];
    640 // CHECK: [[VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 2
    641 // CHECK: [[VAR1_RHS_VOID:%.+]] = load i8*, i8** [[VAR1_RHS_REF]],
    642 // CHECK: [[VAR1_RHS:%.+]] = bitcast i8* [[VAR1_RHS_VOID]] to [[S_INT_TY]]*
    643 // var1_rhs = (S<i{{[0-9]+}}>*)rhs[2];
    644 // CHECK: [[VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 2
    645 // CHECK: [[VAR1_LHS_VOID:%.+]] = load i8*, i8** [[VAR1_LHS_REF]],
    646 // CHECK: [[VAR1_LHS:%.+]] = bitcast i8* [[VAR1_LHS_VOID]] to [[S_INT_TY]]*
    647 
    648 // t_var1_lhs = (i{{[0-9]+}}*)lhs[3];
    649 // CHECK: [[T_VAR1_RHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_RHS]], i64 0, i64 3
    650 // CHECK: [[T_VAR1_RHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_RHS_REF]],
    651 // CHECK: [[T_VAR1_RHS:%.+]] = bitcast i8* [[T_VAR1_RHS_VOID]] to i{{[0-9]+}}*
    652 // t_var1_rhs = (i{{[0-9]+}}*)rhs[3];
    653 // CHECK: [[T_VAR1_LHS_REF:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[RED_LIST_LHS]], i64 0, i64 3
    654 // CHECK: [[T_VAR1_LHS_VOID:%.+]] = load i8*, i8** [[T_VAR1_LHS_REF]],
    655 // CHECK: [[T_VAR1_LHS:%.+]] = bitcast i8* [[T_VAR1_LHS_VOID]] to i{{[0-9]+}}*
    656 
    657 // t_var_lhs += t_var_rhs;
    658 // CHECK: [[T_VAR_LHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_LHS]],
    659 // CHECK: [[T_VAR_RHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_RHS]],
    660 // CHECK: [[UP:%.+]] = add nsw i{{[0-9]+}} [[T_VAR_LHS_VAL]], [[T_VAR_RHS_VAL]]
    661 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR_LHS]],
    662 
    663 // var_lhs = var_lhs.operator &(var_rhs);
    664 // CHECK: [[UP:%.+]] = call dereferenceable(4) [[S_INT_TY]]* @{{.+}}([[S_INT_TY]]* [[VAR_LHS]], [[S_INT_TY]]* dereferenceable(4) [[VAR_RHS]])
    665 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR_LHS]] to i8*
    666 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[UP]] to i8*
    667 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    668 
    669 // var1_lhs = var1_lhs.operator &&(var1_rhs);
    670 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_LHS]])
    671 // CHECK: [[VAR1_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
    672 // CHECK: br i1 [[VAR1_BOOL]], label %[[TRUE:.+]], label %[[END2:.+]]
    673 // CHECK: [[TRUE]]
    674 // CHECK: [[TO_INT:%.+]] = call i{{[0-9]+}} @{{.+}}([[S_INT_TY]]* [[VAR1_RHS]])
    675 // CHECK: [[VAR1_REDUCTION_BOOL:%.+]] = icmp ne i{{[0-9]+}} [[TO_INT]], 0
    676 // CHECK: br label %[[END2]]
    677 // CHECK: [[END2]]
    678 // CHECK: [[COND_LVALUE:%.+]] = phi i1 [ false, %{{.+}} ], [ [[VAR1_REDUCTION_BOOL]], %[[TRUE]] ]
    679 // CHECK: [[CONV:%.+]] = zext i1 [[COND_LVALUE]] to i32
    680 // CHECK:  call void @{{.+}}([[S_INT_TY]]* [[COND_LVALUE:%.+]], i32 [[CONV]])
    681 // CHECK: [[BC1:%.+]] = bitcast [[S_INT_TY]]* [[VAR1_LHS]] to i8*
    682 // CHECK: [[BC2:%.+]] = bitcast [[S_INT_TY]]* [[COND_LVALUE]] to i8*
    683 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[BC1]], i8* [[BC2]], i64 4, i32 4, i1 false)
    684 
    685 // t_var1_lhs = min(t_var1_lhs, t_var1_rhs);
    686 // CHECK: [[T_VAR1_LHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_LHS]],
    687 // CHECK: [[T_VAR1_RHS_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_RHS]],
    688 // CHECK: [[CMP:%.+]] = icmp slt i{{[0-9]+}} [[T_VAR1_LHS_VAL]], [[T_VAR1_RHS_VAL]]
    689 // CHECK: br i1 [[CMP]]
    690 // CHECK: [[UP:%.+]] = phi i32
    691 // CHECK: store i{{[0-9]+}} [[UP]], i{{[0-9]+}}* [[T_VAR1_LHS]],
    692 // CHECK: ret void
    693 
    694 #endif
    695 
    696