1 // Test host codegen.
2 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
4 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix HCHECK
5 // RUN: %clang_cc1 -verify -fopenmp-version=45 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK
8 // Test host codegen.
9 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
10 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
11 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix HCHECK
12 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK
13 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
14 // RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK
15
16 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
17 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
18 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
19 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
20 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
21 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
22 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
23
24 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
25 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
26 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
27 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
28 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
29 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
30 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
31
32 // Test target codegen - host bc file has to be created first. (no significant differences with host version of target region)
33 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
34 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
35 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
36 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
37 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
38 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
39 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
40 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
41
42 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
43 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck --check-prefix SIMD-ONLY1 %s
44 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
45 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
46 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
47 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck --check-prefix SIMD-ONLY1 %s
48 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
49 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
50 // SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
51
52 // expected-no-diagnostics
53 #ifndef HEADER
54 #define HEADER
55
56 // CHECK-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
57 // CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
58 // CHECK-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
59 // CHECK-DAG: [[DEF_LOC_DISTRIBUTE_0:@.+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2050, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
60
61 // CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
without_schedule_clause(float * a,float * b,float * c,float * d)62 void without_schedule_clause(float *a, float *b, float *c, float *d) {
63 #pragma omp target
64 #pragma omp teams
65 #pragma omp distribute
66 for (int i = 33; i < 32000000; i += 7) {
67 a[i] = b[i] * c[i] * d[i];
68 }
69 }
70
71 // CHECK: define {{.*}}void @{{.+}}(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
72 // CHECK: [[TID_ADDR:%.+]] = alloca i32*
73 // CHECK: [[IV:%.+iv]] = alloca i32
74 // CHECK: [[LB:%.+lb]] = alloca i32
75 // CHECK: [[UB:%.+ub]] = alloca i32
76 // CHECK: [[ST:%.+stride]] = alloca i32
77 // CHECK: [[LAST:%.+last]] = alloca i32
78 // CHECK-DAG: store i32* [[GBL_TIDP]], i32** [[TID_ADDR]]
79 // CHECK-DAG: store i32 0, i32* [[LB]]
80 // CHECK-DAG: store i32 4571423, i32* [[UB]]
81 // CHECK-DAG: store i32 1, i32* [[ST]]
82 // CHECK-DAG: store i32 0, i32* [[LAST]]
83 // CHECK-DAG: [[GBL_TID:%.+]] = load i32*, i32** [[TID_ADDR]]
84 // CHECK-DAG: [[GBL_TIDV:%.+]] = load i32, i32* [[GBL_TID]]
85 // CHECK: call void @__kmpc_for_static_init_{{.+}}(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]], i32 92, i32* %.omp.is_last, i32* %.omp.lb, i32* %.omp.ub, i32* %.omp.stride, i32 1, i32 1)
86 // CHECK-DAG: [[UBV0:%.+]] = load i32, i32* [[UB]]
87 // CHECK-DAG: [[USWITCH:%.+]] = icmp sgt i32 [[UBV0]], 4571423
88 // CHECK: br i1 [[USWITCH]], label %[[BBCT:.+]], label %[[BBCF:.+]]
89 // CHECK-DAG: [[BBCT]]:
90 // CHECK-DAG: br label %[[BBCE:.+]]
91 // CHECK-DAG: [[BBCF]]:
92 // CHECK-DAG: [[UBV1:%.+]] = load i32, i32* [[UB]]
93 // CHECK-DAG: br label %[[BBCE]]
94 // CHECK: [[BBCE]]:
95 // CHECK: [[SELUB:%.+]] = phi i32 [ 4571423, %[[BBCT]] ], [ [[UBV1]], %[[BBCF]] ]
96 // CHECK: store i32 [[SELUB]], i32* [[UB]]
97 // CHECK: [[LBV0:%.+]] = load i32, i32* [[LB]]
98 // CHECK: store i32 [[LBV0]], i32* [[IV]]
99 // CHECK: br label %[[BBINNFOR:.+]]
100 // CHECK: [[BBINNFOR]]:
101 // CHECK: [[IVVAL0:%.+]] = load i32, i32* [[IV]]
102 // CHECK: [[UBV2:%.+]] = load i32, i32* [[UB]]
103 // CHECK: [[IVLEUB:%.+]] = icmp sle i32 [[IVVAL0]], [[UBV2]]
104 // CHECK: br i1 [[IVLEUB]], label %[[BBINNBODY:.+]], label %[[BBINNEND:.+]]
105 // CHECK: [[BBINNBODY]]:
106 // CHECK: {{.+}} = load i32, i32* [[IV]]
107 // ... loop body ...
108 // CHECK: br label %[[BBBODYCONT:.+]]
109 // CHECK: [[BBBODYCONT]]:
110 // CHECK: br label %[[BBINNINC:.+]]
111 // CHECK: [[BBINNINC]]:
112 // CHECK: [[IVVAL1:%.+]] = load i32, i32* [[IV]]
113 // CHECK: [[IVINC:%.+]] = add nsw i32 [[IVVAL1]], 1
114 // CHECK: store i32 [[IVINC]], i32* [[IV]]
115 // CHECK: br label %[[BBINNFOR]]
116 // CHECK: [[BBINNEND]]:
117 // CHECK: br label %[[LPEXIT:.+]]
118 // CHECK: [[LPEXIT]]:
119 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
120 // CHECK: ret void
121
122
123 // CHECK-LABEL: define {{.*void}} @{{.*}}static_not_chunked{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
static_not_chunked(float * a,float * b,float * c,float * d)124 void static_not_chunked(float *a, float *b, float *c, float *d) {
125 #pragma omp target
126 #pragma omp teams
127 #pragma omp distribute dist_schedule(static)
128 for (int i = 32000000; i > 33; i += -7) {
129 a[i] = b[i] * c[i] * d[i];
130 }
131 }
132
133 // CHECK: define {{.*}}void @.omp_outlined.{{.*}}(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
134 // CHECK: [[TID_ADDR:%.+]] = alloca i32*
135 // CHECK: [[IV:%.+iv]] = alloca i32
136 // CHECK: [[LB:%.+lb]] = alloca i32
137 // CHECK: [[UB:%.+ub]] = alloca i32
138 // CHECK: [[ST:%.+stride]] = alloca i32
139 // CHECK: [[LAST:%.+last]] = alloca i32
140 // CHECK-DAG: store i32* [[GBL_TIDP]], i32** [[TID_ADDR]]
141 // CHECK-DAG: store i32 0, i32* [[LB]]
142 // CHECK-DAG: store i32 4571423, i32* [[UB]]
143 // CHECK-DAG: store i32 1, i32* [[ST]]
144 // CHECK-DAG: store i32 0, i32* [[LAST]]
145 // CHECK-DAG: [[GBL_TID:%.+]] = load i32*, i32** [[TID_ADDR]]
146 // CHECK-DAG: [[GBL_TIDV:%.+]] = load i32, i32* [[GBL_TID]]
147 // CHECK: call void @__kmpc_for_static_init_{{.+}}(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]], i32 92, i32* %.omp.is_last, i32* %.omp.lb, i32* %.omp.ub, i32* %.omp.stride, i32 1, i32 1)
148 // CHECK-DAG: [[UBV0:%.+]] = load i32, i32* [[UB]]
149 // CHECK-DAG: [[USWITCH:%.+]] = icmp sgt i32 [[UBV0]], 4571423
150 // CHECK: br i1 [[USWITCH]], label %[[BBCT:.+]], label %[[BBCF:.+]]
151 // CHECK-DAG: [[BBCT]]:
152 // CHECK-DAG: br label %[[BBCE:.+]]
153 // CHECK-DAG: [[BBCF]]:
154 // CHECK-DAG: [[UBV1:%.+]] = load i32, i32* [[UB]]
155 // CHECK-DAG: br label %[[BBCE]]
156 // CHECK: [[BBCE]]:
157 // CHECK: [[SELUB:%.+]] = phi i32 [ 4571423, %[[BBCT]] ], [ [[UBV1]], %[[BBCF]] ]
158 // CHECK: store i32 [[SELUB]], i32* [[UB]]
159 // CHECK: [[LBV0:%.+]] = load i32, i32* [[LB]]
160 // CHECK: store i32 [[LBV0]], i32* [[IV]]
161 // CHECK: br label %[[BBINNFOR:.+]]
162 // CHECK: [[BBINNFOR]]:
163 // CHECK: [[IVVAL0:%.+]] = load i32, i32* [[IV]]
164 // CHECK: [[UBV2:%.+]] = load i32, i32* [[UB]]
165 // CHECK: [[IVLEUB:%.+]] = icmp sle i32 [[IVVAL0]], [[UBV2]]
166 // CHECK: br i1 [[IVLEUB]], label %[[BBINNBODY:.+]], label %[[BBINNEND:.+]]
167 // CHECK: [[BBINNBODY]]:
168 // CHECK: {{.+}} = load i32, i32* [[IV]]
169 // ... loop body ...
170 // CHECK: br label %[[BBBODYCONT:.+]]
171 // CHECK: [[BBBODYCONT]]:
172 // CHECK: br label %[[BBINNINC:.+]]
173 // CHECK: [[BBINNINC]]:
174 // CHECK: [[IVVAL1:%.+]] = load i32, i32* [[IV]]
175 // CHECK: [[IVINC:%.+]] = add nsw i32 [[IVVAL1]], 1
176 // CHECK: store i32 [[IVINC]], i32* [[IV]]
177 // CHECK: br label %[[BBINNFOR]]
178 // CHECK: [[BBINNEND]]:
179 // CHECK: br label %[[LPEXIT:.+]]
180 // CHECK: [[LPEXIT]]:
181 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
182 // CHECK: ret void
183
184
185 // CHECK-LABEL: define {{.*void}} @{{.*}}static_chunked{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
static_chunked(float * a,float * b,float * c,float * d)186 void static_chunked(float *a, float *b, float *c, float *d) {
187 #pragma omp target
188 #pragma omp teams
189 #pragma omp distribute dist_schedule(static, 5)
190 for (unsigned i = 131071; i <= 2147483647; i += 127) {
191 a[i] = b[i] * c[i] * d[i];
192 }
193 }
194
195 // CHECK: define {{.*}}void @.omp_outlined.{{.*}}(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
196 // CHECK: [[TID_ADDR:%.+]] = alloca i32*
197 // CHECK: [[IV:%.+iv]] = alloca i32
198 // CHECK: [[LB:%.+lb]] = alloca i32
199 // CHECK: [[UB:%.+ub]] = alloca i32
200 // CHECK: [[ST:%.+stride]] = alloca i32
201 // CHECK: [[LAST:%.+last]] = alloca i32
202 // CHECK-DAG: store i32* [[GBL_TIDP]], i32** [[TID_ADDR]]
203 // CHECK-DAG: store i32 0, i32* [[LB]]
204 // CHECK-DAG: store i32 16908288, i32* [[UB]]
205 // CHECK-DAG: store i32 1, i32* [[ST]]
206 // CHECK-DAG: store i32 0, i32* [[LAST]]
207 // CHECK-DAG: [[GBL_TID:%.+]] = load i32*, i32** [[TID_ADDR]]
208 // CHECK-DAG: [[GBL_TIDV:%.+]] = load i32, i32* [[GBL_TID]]
209 // CHECK: call void @__kmpc_for_static_init_{{.+}}(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]], i32 91, i32* %.omp.is_last, i32* %.omp.lb, i32* %.omp.ub, i32* %.omp.stride, i32 1, i32 5)
210 // CHECK-DAG: [[UBV0:%.+]] = load i32, i32* [[UB]]
211 // CHECK-DAG: [[USWITCH:%.+]] = icmp ugt i32 [[UBV0]], 16908288
212 // CHECK: br i1 [[USWITCH]], label %[[BBCT:.+]], label %[[BBCF:.+]]
213 // CHECK-DAG: [[BBCT]]:
214 // CHECK-DAG: br label %[[BBCE:.+]]
215 // CHECK-DAG: [[BBCF]]:
216 // CHECK-DAG: [[UBV1:%.+]] = load i32, i32* [[UB]]
217 // CHECK-DAG: br label %[[BBCE]]
218 // CHECK: [[BBCE]]:
219 // CHECK: [[SELUB:%.+]] = phi i32 [ 16908288, %[[BBCT]] ], [ [[UBV1]], %[[BBCF]] ]
220 // CHECK: store i32 [[SELUB]], i32* [[UB]]
221 // CHECK: [[LBV0:%.+]] = load i32, i32* [[LB]]
222 // CHECK: store i32 [[LBV0]], i32* [[IV]]
223 // CHECK: br label %[[BBINNFOR:.+]]
224 // CHECK: [[BBINNFOR]]:
225 // CHECK: [[IVVAL0:%.+]] = load i32, i32* [[IV]]
226 // CHECK: [[UBV2:%.+]] = load i32, i32* [[UB]]
227 // CHECK: [[IVLEUB:%.+]] = icmp ule i32 [[IVVAL0]], [[UBV2]]
228 // CHECK: br i1 [[IVLEUB]], label %[[BBINNBODY:.+]], label %[[BBINNEND:.+]]
229 // CHECK: [[BBINNBODY]]:
230 // CHECK: {{.+}} = load i32, i32* [[IV]]
231 // ... loop body ...
232 // CHECK: br label %[[BBBODYCONT:.+]]
233 // CHECK: [[BBBODYCONT]]:
234 // CHECK: br label %[[BBINNINC:.+]]
235 // CHECK: [[BBINNINC]]:
236 // CHECK: [[IVVAL1:%.+]] = load i32, i32* [[IV]]
237 // CHECK: [[IVINC:%.+]] = add i32 [[IVVAL1]], 1
238 // CHECK: store i32 [[IVINC]], i32* [[IV]]
239 // CHECK: br label %[[BBINNFOR]]
240 // CHECK: [[BBINNEND]]:
241 // CHECK: br label %[[LPEXIT:.+]]
242 // CHECK: [[LPEXIT]]:
243 // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* [[DEF_LOC_DISTRIBUTE_0]], i32 [[GBL_TIDV]])
244 // CHECK: ret void
245
246 // CHECK-LABEL: test_precond
test_precond()247 void test_precond() {
248 char a = 0;
249 #pragma omp target
250 #pragma omp teams
251 #pragma omp distribute
252 for(char i = a; i < 10; ++i);
253 }
254
255 // a is passed as a parameter to the outlined functions
256 // CHECK: define {{.*}}void @.omp_outlined.{{.*}}(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], i8* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[APARM:%.+]])
257 // CHECK: store i8* [[APARM]], i8** [[APTRADDR:%.+]]
258 // ..many loads of %0..
259 // CHECK: [[A2:%.+]] = load i8*, i8** [[APTRADDR]]
260 // CHECK: [[AVAL0:%.+]] = load i8, i8* [[A2]]
261 // CHECK: store i8 [[AVAL0]], i8* [[CAP_EXPR:%.+]],
262 // CHECK: [[AVAL1:%.+]] = load i8, i8* [[CAP_EXPR]]
263 // CHECK: load i8, i8* [[CAP_EXPR]]
264 // CHECK: [[AVAL2:%.+]] = load i8, i8* [[CAP_EXPR]]
265 // CHECK: [[ACONV:%.+]] = sext i8 [[AVAL2]] to i32
266 // CHECK: [[ACMP:%.+]] = icmp slt i32 [[ACONV]], 10
267 // CHECK: br i1 [[ACMP]], label %[[PRECOND_THEN:.+]], label %[[PRECOND_END:.+]]
268 // CHECK: [[PRECOND_THEN]]
269 // CHECK: call void @__kmpc_for_static_init_4
270 // CHECK: call void @__kmpc_for_static_fini
271 // CHECK: [[PRECOND_END]]
272
273 // no templates for now, as these require special handling in target regions and/or declare target
274
275 // HCHECK-LABEL: fint
276 // HCHECK: call {{.*}}i32 {{.+}}ftemplate
277 // HCHECK: ret i32
278
279 // HCHECK: load i16, i16*
280 // HCHECK: store i16 %
281 // HCHECK: call i32 @__tgt_target_teams_mapper(%struct.ident_t* @{{.+}},
282 // HCHECK: call void @__kmpc_for_static_init_4(
283 template <typename T>
ftemplate()284 T ftemplate() {
285 short aa = 0;
286
287 #pragma omp target
288 #pragma omp teams
289 #pragma omp distribute dist_schedule(static, aa)
290 for (int i = 0; i < 100; i++) {
291 }
292 return T();
293 }
294
fint(void)295 int fint(void) { return ftemplate<int>(); }
296
297 #endif
298