1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
2 // Test target codegen - host bc file has to be created first.
3 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK1
5 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
6 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix=CHECK2
7 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix=CHECK2
9 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
10 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK1
11 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
12 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix=CHECK2
13 // RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix=CHECK2
15 // expected-no-diagnostics
23 int main(int argc
, char **argv
) {
24 #pragma omp target teams loop map(tofrom:a) if(target:argc)
25 for (int i
= 0; i
< argc
; ++i
)
26 a
= foo(&i
) + foo(&a
) + foo(&argc
);
32 // CHECK1-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24
33 // CHECK1-SAME: (ptr noalias noundef [[DYN_PTR:%.*]], i64 noundef [[ARGC:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR0:[0-9]+]] {
34 // CHECK1-NEXT: entry:
35 // CHECK1-NEXT: [[DYN_PTR_ADDR:%.*]] = alloca ptr, align 8
36 // CHECK1-NEXT: [[ARGC_ADDR:%.*]] = alloca i64, align 8
37 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
38 // CHECK1-NEXT: [[ARGC_CASTED:%.*]] = alloca i64, align 8
39 // CHECK1-NEXT: [[DOTZERO_ADDR:%.*]] = alloca i32, align 4
40 // CHECK1-NEXT: [[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4
41 // CHECK1-NEXT: store ptr [[DYN_PTR]], ptr [[DYN_PTR_ADDR]], align 8
42 // CHECK1-NEXT: store i64 [[ARGC]], ptr [[ARGC_ADDR]], align 8
43 // CHECK1-NEXT: store ptr [[A]], ptr [[A_ADDR]], align 8
44 // CHECK1-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
45 // CHECK1-NEXT: [[TMP1:%.*]] = call i32 @__kmpc_target_init(ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_kernel_environment, ptr [[DYN_PTR]])
46 // CHECK1-NEXT: [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP1]], -1
47 // CHECK1-NEXT: br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]]
48 // CHECK1: user_code.entry:
49 // CHECK1-NEXT: [[TMP2:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
50 // CHECK1-NEXT: [[TMP3:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
51 // CHECK1-NEXT: store i32 [[TMP3]], ptr [[ARGC_CASTED]], align 4
52 // CHECK1-NEXT: [[TMP4:%.*]] = load i64, ptr [[ARGC_CASTED]], align 8
53 // CHECK1-NEXT: store i32 0, ptr [[DOTZERO_ADDR]], align 4
54 // CHECK1-NEXT: store i32 [[TMP2]], ptr [[DOTTHREADID_TEMP_]], align 4
55 // CHECK1-NEXT: call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_omp_outlined(ptr [[DOTTHREADID_TEMP_]], ptr [[DOTZERO_ADDR]], i64 [[TMP4]], ptr [[TMP0]]) #[[ATTR2:[0-9]+]]
56 // CHECK1-NEXT: call void @__kmpc_target_deinit()
57 // CHECK1-NEXT: ret void
58 // CHECK1: worker.exit:
59 // CHECK1-NEXT: ret void
62 // CHECK1-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_omp_outlined
63 // CHECK1-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]], i64 noundef [[ARGC:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR1:[0-9]+]] {
64 // CHECK1-NEXT: entry:
65 // CHECK1-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
66 // CHECK1-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
67 // CHECK1-NEXT: [[ARGC_ADDR:%.*]] = alloca i64, align 8
68 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
69 // CHECK1-NEXT: [[DOTOMP_IV:%.*]] = alloca i32, align 4
70 // CHECK1-NEXT: [[TMP:%.*]] = alloca i32, align 4
71 // CHECK1-NEXT: [[DOTCAPTURE_EXPR_:%.*]] = alloca i32, align 4
72 // CHECK1-NEXT: [[DOTCAPTURE_EXPR_1:%.*]] = alloca i32, align 4
73 // CHECK1-NEXT: [[I:%.*]] = alloca i32, align 4
74 // CHECK1-NEXT: [[DOTOMP_COMB_LB:%.*]] = alloca i32, align 4
75 // CHECK1-NEXT: [[DOTOMP_COMB_UB:%.*]] = alloca i32, align 4
76 // CHECK1-NEXT: [[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
77 // CHECK1-NEXT: [[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
78 // CHECK1-NEXT: [[I3:%.*]] = alloca i32, align 4
79 // CHECK1-NEXT: [[ARGC_CASTED:%.*]] = alloca i64, align 8
80 // CHECK1-NEXT: [[CAPTURED_VARS_ADDRS:%.*]] = alloca [4 x ptr], align 8
81 // CHECK1-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
82 // CHECK1-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
83 // CHECK1-NEXT: store i64 [[ARGC]], ptr [[ARGC_ADDR]], align 8
84 // CHECK1-NEXT: store ptr [[A]], ptr [[A_ADDR]], align 8
85 // CHECK1-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
86 // CHECK1-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
87 // CHECK1-NEXT: store i32 [[TMP1]], ptr [[DOTCAPTURE_EXPR_]], align 4
88 // CHECK1-NEXT: [[TMP2:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
89 // CHECK1-NEXT: [[SUB:%.*]] = sub nsw i32 [[TMP2]], 0
90 // CHECK1-NEXT: [[DIV:%.*]] = sdiv i32 [[SUB]], 1
91 // CHECK1-NEXT: [[SUB2:%.*]] = sub nsw i32 [[DIV]], 1
92 // CHECK1-NEXT: store i32 [[SUB2]], ptr [[DOTCAPTURE_EXPR_1]], align 4
93 // CHECK1-NEXT: store i32 0, ptr [[I]], align 4
94 // CHECK1-NEXT: [[TMP3:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
95 // CHECK1-NEXT: [[CMP:%.*]] = icmp slt i32 0, [[TMP3]]
96 // CHECK1-NEXT: br i1 [[CMP]], label [[OMP_PRECOND_THEN:%.*]], label [[OMP_PRECOND_END:%.*]]
97 // CHECK1: omp.precond.then:
98 // CHECK1-NEXT: store i32 0, ptr [[DOTOMP_COMB_LB]], align 4
99 // CHECK1-NEXT: [[TMP4:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
100 // CHECK1-NEXT: store i32 [[TMP4]], ptr [[DOTOMP_COMB_UB]], align 4
101 // CHECK1-NEXT: store i32 1, ptr [[DOTOMP_STRIDE]], align 4
102 // CHECK1-NEXT: store i32 0, ptr [[DOTOMP_IS_LAST]], align 4
103 // CHECK1-NEXT: [[NVPTX_NUM_THREADS:%.*]] = call i32 @__kmpc_get_hardware_num_threads_in_block()
104 // CHECK1-NEXT: [[TMP5:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
105 // CHECK1-NEXT: [[TMP6:%.*]] = load i32, ptr [[TMP5]], align 4
106 // CHECK1-NEXT: call void @__kmpc_distribute_static_init_4(ptr @[[GLOB2:[0-9]+]], i32 [[TMP6]], i32 91, ptr [[DOTOMP_IS_LAST]], ptr [[DOTOMP_COMB_LB]], ptr [[DOTOMP_COMB_UB]], ptr [[DOTOMP_STRIDE]], i32 1, i32 [[NVPTX_NUM_THREADS]])
107 // CHECK1-NEXT: [[TMP7:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
108 // CHECK1-NEXT: [[TMP8:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
109 // CHECK1-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[TMP7]], [[TMP8]]
110 // CHECK1-NEXT: br i1 [[CMP4]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
111 // CHECK1: cond.true:
112 // CHECK1-NEXT: [[TMP9:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
113 // CHECK1-NEXT: br label [[COND_END:%.*]]
114 // CHECK1: cond.false:
115 // CHECK1-NEXT: [[TMP10:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
116 // CHECK1-NEXT: br label [[COND_END]]
118 // CHECK1-NEXT: [[COND:%.*]] = phi i32 [ [[TMP9]], [[COND_TRUE]] ], [ [[TMP10]], [[COND_FALSE]] ]
119 // CHECK1-NEXT: store i32 [[COND]], ptr [[DOTOMP_COMB_UB]], align 4
120 // CHECK1-NEXT: [[TMP11:%.*]] = load i32, ptr [[DOTOMP_COMB_LB]], align 4
121 // CHECK1-NEXT: store i32 [[TMP11]], ptr [[DOTOMP_IV]], align 4
122 // CHECK1-NEXT: br label [[OMP_INNER_FOR_COND:%.*]]
123 // CHECK1: omp.inner.for.cond:
124 // CHECK1-NEXT: [[TMP12:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
125 // CHECK1-NEXT: [[TMP13:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
126 // CHECK1-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP13]], 1
127 // CHECK1-NEXT: [[CMP5:%.*]] = icmp slt i32 [[TMP12]], [[ADD]]
128 // CHECK1-NEXT: br i1 [[CMP5]], label [[OMP_INNER_FOR_BODY:%.*]], label [[OMP_INNER_FOR_END:%.*]]
129 // CHECK1: omp.inner.for.body:
130 // CHECK1-NEXT: [[TMP14:%.*]] = load i32, ptr [[DOTOMP_COMB_LB]], align 4
131 // CHECK1-NEXT: [[TMP15:%.*]] = zext i32 [[TMP14]] to i64
132 // CHECK1-NEXT: [[TMP16:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
133 // CHECK1-NEXT: [[TMP17:%.*]] = zext i32 [[TMP16]] to i64
134 // CHECK1-NEXT: [[TMP18:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
135 // CHECK1-NEXT: store i32 [[TMP18]], ptr [[ARGC_CASTED]], align 4
136 // CHECK1-NEXT: [[TMP19:%.*]] = load i64, ptr [[ARGC_CASTED]], align 8
137 // CHECK1-NEXT: [[TMP20:%.*]] = getelementptr inbounds [4 x ptr], ptr [[CAPTURED_VARS_ADDRS]], i64 0, i64 0
138 // CHECK1-NEXT: [[TMP21:%.*]] = inttoptr i64 [[TMP15]] to ptr
139 // CHECK1-NEXT: store ptr [[TMP21]], ptr [[TMP20]], align 8
140 // CHECK1-NEXT: [[TMP22:%.*]] = getelementptr inbounds [4 x ptr], ptr [[CAPTURED_VARS_ADDRS]], i64 0, i64 1
141 // CHECK1-NEXT: [[TMP23:%.*]] = inttoptr i64 [[TMP17]] to ptr
142 // CHECK1-NEXT: store ptr [[TMP23]], ptr [[TMP22]], align 8
143 // CHECK1-NEXT: [[TMP24:%.*]] = getelementptr inbounds [4 x ptr], ptr [[CAPTURED_VARS_ADDRS]], i64 0, i64 2
144 // CHECK1-NEXT: [[TMP25:%.*]] = inttoptr i64 [[TMP19]] to ptr
145 // CHECK1-NEXT: store ptr [[TMP25]], ptr [[TMP24]], align 8
146 // CHECK1-NEXT: [[TMP26:%.*]] = getelementptr inbounds [4 x ptr], ptr [[CAPTURED_VARS_ADDRS]], i64 0, i64 3
147 // CHECK1-NEXT: store ptr [[TMP0]], ptr [[TMP26]], align 8
148 // CHECK1-NEXT: [[TMP27:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
149 // CHECK1-NEXT: [[TMP28:%.*]] = load i32, ptr [[TMP27]], align 4
150 // CHECK1-NEXT: call void @__kmpc_parallel_51(ptr @[[GLOB1]], i32 [[TMP28]], i32 1, i32 -1, i32 -1, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_omp_outlined_omp_outlined, ptr null, ptr [[CAPTURED_VARS_ADDRS]], i64 4)
151 // CHECK1-NEXT: br label [[OMP_INNER_FOR_INC:%.*]]
152 // CHECK1: omp.inner.for.inc:
153 // CHECK1-NEXT: [[TMP29:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
154 // CHECK1-NEXT: [[TMP30:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
155 // CHECK1-NEXT: [[ADD6:%.*]] = add nsw i32 [[TMP29]], [[TMP30]]
156 // CHECK1-NEXT: store i32 [[ADD6]], ptr [[DOTOMP_IV]], align 4
157 // CHECK1-NEXT: [[TMP31:%.*]] = load i32, ptr [[DOTOMP_COMB_LB]], align 4
158 // CHECK1-NEXT: [[TMP32:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
159 // CHECK1-NEXT: [[ADD7:%.*]] = add nsw i32 [[TMP31]], [[TMP32]]
160 // CHECK1-NEXT: store i32 [[ADD7]], ptr [[DOTOMP_COMB_LB]], align 4
161 // CHECK1-NEXT: [[TMP33:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
162 // CHECK1-NEXT: [[TMP34:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
163 // CHECK1-NEXT: [[ADD8:%.*]] = add nsw i32 [[TMP33]], [[TMP34]]
164 // CHECK1-NEXT: store i32 [[ADD8]], ptr [[DOTOMP_COMB_UB]], align 4
165 // CHECK1-NEXT: [[TMP35:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
166 // CHECK1-NEXT: [[TMP36:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
167 // CHECK1-NEXT: [[CMP9:%.*]] = icmp sgt i32 [[TMP35]], [[TMP36]]
168 // CHECK1-NEXT: br i1 [[CMP9]], label [[COND_TRUE10:%.*]], label [[COND_FALSE11:%.*]]
169 // CHECK1: cond.true10:
170 // CHECK1-NEXT: [[TMP37:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
171 // CHECK1-NEXT: br label [[COND_END12:%.*]]
172 // CHECK1: cond.false11:
173 // CHECK1-NEXT: [[TMP38:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
174 // CHECK1-NEXT: br label [[COND_END12]]
175 // CHECK1: cond.end12:
176 // CHECK1-NEXT: [[COND13:%.*]] = phi i32 [ [[TMP37]], [[COND_TRUE10]] ], [ [[TMP38]], [[COND_FALSE11]] ]
177 // CHECK1-NEXT: store i32 [[COND13]], ptr [[DOTOMP_COMB_UB]], align 4
178 // CHECK1-NEXT: [[TMP39:%.*]] = load i32, ptr [[DOTOMP_COMB_LB]], align 4
179 // CHECK1-NEXT: store i32 [[TMP39]], ptr [[DOTOMP_IV]], align 4
180 // CHECK1-NEXT: br label [[OMP_INNER_FOR_COND]]
181 // CHECK1: omp.inner.for.end:
182 // CHECK1-NEXT: br label [[OMP_LOOP_EXIT:%.*]]
183 // CHECK1: omp.loop.exit:
184 // CHECK1-NEXT: [[TMP40:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
185 // CHECK1-NEXT: [[TMP41:%.*]] = load i32, ptr [[TMP40]], align 4
186 // CHECK1-NEXT: call void @__kmpc_for_static_fini(ptr @[[GLOB3:[0-9]+]], i32 [[TMP41]])
187 // CHECK1-NEXT: br label [[OMP_PRECOND_END]]
188 // CHECK1: omp.precond.end:
189 // CHECK1-NEXT: ret void
192 // CHECK1-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_omp_outlined_omp_outlined
193 // CHECK1-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]], i64 noundef [[DOTPREVIOUS_LB_:%.*]], i64 noundef [[DOTPREVIOUS_UB_:%.*]], i64 noundef [[ARGC:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR1]] {
194 // CHECK1-NEXT: entry:
195 // CHECK1-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
196 // CHECK1-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
197 // CHECK1-NEXT: [[DOTPREVIOUS_LB__ADDR:%.*]] = alloca i64, align 8
198 // CHECK1-NEXT: [[DOTPREVIOUS_UB__ADDR:%.*]] = alloca i64, align 8
199 // CHECK1-NEXT: [[ARGC_ADDR:%.*]] = alloca i64, align 8
200 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 8
201 // CHECK1-NEXT: [[DOTOMP_IV:%.*]] = alloca i32, align 4
202 // CHECK1-NEXT: [[TMP:%.*]] = alloca i32, align 4
203 // CHECK1-NEXT: [[DOTCAPTURE_EXPR_:%.*]] = alloca i32, align 4
204 // CHECK1-NEXT: [[DOTCAPTURE_EXPR_1:%.*]] = alloca i32, align 4
205 // CHECK1-NEXT: [[I:%.*]] = alloca i32, align 4
206 // CHECK1-NEXT: [[DOTOMP_LB:%.*]] = alloca i32, align 4
207 // CHECK1-NEXT: [[DOTOMP_UB:%.*]] = alloca i32, align 4
208 // CHECK1-NEXT: [[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
209 // CHECK1-NEXT: [[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
210 // CHECK1-NEXT: [[I4:%.*]] = alloca i32, align 4
211 // CHECK1-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
212 // CHECK1-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
213 // CHECK1-NEXT: store i64 [[DOTPREVIOUS_LB_]], ptr [[DOTPREVIOUS_LB__ADDR]], align 8
214 // CHECK1-NEXT: store i64 [[DOTPREVIOUS_UB_]], ptr [[DOTPREVIOUS_UB__ADDR]], align 8
215 // CHECK1-NEXT: store i64 [[ARGC]], ptr [[ARGC_ADDR]], align 8
216 // CHECK1-NEXT: store ptr [[A]], ptr [[A_ADDR]], align 8
217 // CHECK1-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
218 // CHECK1-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
219 // CHECK1-NEXT: store i32 [[TMP1]], ptr [[DOTCAPTURE_EXPR_]], align 4
220 // CHECK1-NEXT: [[TMP2:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
221 // CHECK1-NEXT: [[SUB:%.*]] = sub nsw i32 [[TMP2]], 0
222 // CHECK1-NEXT: [[DIV:%.*]] = sdiv i32 [[SUB]], 1
223 // CHECK1-NEXT: [[SUB2:%.*]] = sub nsw i32 [[DIV]], 1
224 // CHECK1-NEXT: store i32 [[SUB2]], ptr [[DOTCAPTURE_EXPR_1]], align 4
225 // CHECK1-NEXT: store i32 0, ptr [[I]], align 4
226 // CHECK1-NEXT: [[TMP3:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
227 // CHECK1-NEXT: [[CMP:%.*]] = icmp slt i32 0, [[TMP3]]
228 // CHECK1-NEXT: br i1 [[CMP]], label [[OMP_PRECOND_THEN:%.*]], label [[OMP_PRECOND_END:%.*]]
229 // CHECK1: omp.precond.then:
230 // CHECK1-NEXT: store i32 0, ptr [[DOTOMP_LB]], align 4
231 // CHECK1-NEXT: [[TMP4:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
232 // CHECK1-NEXT: store i32 [[TMP4]], ptr [[DOTOMP_UB]], align 4
233 // CHECK1-NEXT: [[TMP5:%.*]] = load i64, ptr [[DOTPREVIOUS_LB__ADDR]], align 8
234 // CHECK1-NEXT: [[CONV:%.*]] = trunc i64 [[TMP5]] to i32
235 // CHECK1-NEXT: [[TMP6:%.*]] = load i64, ptr [[DOTPREVIOUS_UB__ADDR]], align 8
236 // CHECK1-NEXT: [[CONV3:%.*]] = trunc i64 [[TMP6]] to i32
237 // CHECK1-NEXT: store i32 [[CONV]], ptr [[DOTOMP_LB]], align 4
238 // CHECK1-NEXT: store i32 [[CONV3]], ptr [[DOTOMP_UB]], align 4
239 // CHECK1-NEXT: store i32 1, ptr [[DOTOMP_STRIDE]], align 4
240 // CHECK1-NEXT: store i32 0, ptr [[DOTOMP_IS_LAST]], align 4
241 // CHECK1-NEXT: [[TMP7:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
242 // CHECK1-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP7]], align 4
243 // CHECK1-NEXT: call void @__kmpc_for_static_init_4(ptr @[[GLOB3]], i32 [[TMP8]], i32 33, ptr [[DOTOMP_IS_LAST]], ptr [[DOTOMP_LB]], ptr [[DOTOMP_UB]], ptr [[DOTOMP_STRIDE]], i32 1, i32 1)
244 // CHECK1-NEXT: [[TMP9:%.*]] = load i32, ptr [[DOTOMP_LB]], align 4
245 // CHECK1-NEXT: store i32 [[TMP9]], ptr [[DOTOMP_IV]], align 4
246 // CHECK1-NEXT: br label [[OMP_INNER_FOR_COND:%.*]]
247 // CHECK1: omp.inner.for.cond:
248 // CHECK1-NEXT: [[TMP10:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
249 // CHECK1-NEXT: [[CONV5:%.*]] = sext i32 [[TMP10]] to i64
250 // CHECK1-NEXT: [[TMP11:%.*]] = load i64, ptr [[DOTPREVIOUS_UB__ADDR]], align 8
251 // CHECK1-NEXT: [[CMP6:%.*]] = icmp ule i64 [[CONV5]], [[TMP11]]
252 // CHECK1-NEXT: br i1 [[CMP6]], label [[OMP_INNER_FOR_BODY:%.*]], label [[OMP_INNER_FOR_END:%.*]]
253 // CHECK1: omp.inner.for.body:
254 // CHECK1-NEXT: [[TMP12:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
255 // CHECK1-NEXT: [[MUL:%.*]] = mul nsw i32 [[TMP12]], 1
256 // CHECK1-NEXT: [[ADD:%.*]] = add nsw i32 0, [[MUL]]
257 // CHECK1-NEXT: store i32 [[ADD]], ptr [[I4]], align 4
258 // CHECK1-NEXT: [[CALL:%.*]] = call noundef i32 @_Z3fooPi(ptr noundef [[I4]]) #[[ATTR5:[0-9]+]]
259 // CHECK1-NEXT: [[CALL7:%.*]] = call noundef i32 @_Z3fooPi(ptr noundef [[TMP0]]) #[[ATTR5]]
260 // CHECK1-NEXT: [[ADD8:%.*]] = add nsw i32 [[CALL]], [[CALL7]]
261 // CHECK1-NEXT: [[CALL9:%.*]] = call noundef i32 @_Z3fooPi(ptr noundef [[ARGC_ADDR]]) #[[ATTR5]]
262 // CHECK1-NEXT: [[ADD10:%.*]] = add nsw i32 [[ADD8]], [[CALL9]]
263 // CHECK1-NEXT: store i32 [[ADD10]], ptr [[TMP0]], align 4
264 // CHECK1-NEXT: br label [[OMP_BODY_CONTINUE:%.*]]
265 // CHECK1: omp.body.continue:
266 // CHECK1-NEXT: br label [[OMP_INNER_FOR_INC:%.*]]
267 // CHECK1: omp.inner.for.inc:
268 // CHECK1-NEXT: [[TMP13:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
269 // CHECK1-NEXT: [[TMP14:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
270 // CHECK1-NEXT: [[ADD11:%.*]] = add nsw i32 [[TMP13]], [[TMP14]]
271 // CHECK1-NEXT: store i32 [[ADD11]], ptr [[DOTOMP_IV]], align 4
272 // CHECK1-NEXT: br label [[OMP_INNER_FOR_COND]]
273 // CHECK1: omp.inner.for.end:
274 // CHECK1-NEXT: br label [[OMP_LOOP_EXIT:%.*]]
275 // CHECK1: omp.loop.exit:
276 // CHECK1-NEXT: [[TMP15:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
277 // CHECK1-NEXT: [[TMP16:%.*]] = load i32, ptr [[TMP15]], align 4
278 // CHECK1-NEXT: call void @__kmpc_for_static_fini(ptr @[[GLOB3]], i32 [[TMP16]])
279 // CHECK1-NEXT: br label [[OMP_PRECOND_END]]
280 // CHECK1: omp.precond.end:
281 // CHECK1-NEXT: ret void
284 // CHECK2-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24
285 // CHECK2-SAME: (ptr noalias noundef [[DYN_PTR:%.*]], i32 noundef [[ARGC:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR0:[0-9]+]] {
286 // CHECK2-NEXT: entry:
287 // CHECK2-NEXT: [[DYN_PTR_ADDR:%.*]] = alloca ptr, align 4
288 // CHECK2-NEXT: [[ARGC_ADDR:%.*]] = alloca i32, align 4
289 // CHECK2-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 4
290 // CHECK2-NEXT: [[ARGC_CASTED:%.*]] = alloca i32, align 4
291 // CHECK2-NEXT: [[DOTZERO_ADDR:%.*]] = alloca i32, align 4
292 // CHECK2-NEXT: [[DOTTHREADID_TEMP_:%.*]] = alloca i32, align 4
293 // CHECK2-NEXT: store ptr [[DYN_PTR]], ptr [[DYN_PTR_ADDR]], align 4
294 // CHECK2-NEXT: store i32 [[ARGC]], ptr [[ARGC_ADDR]], align 4
295 // CHECK2-NEXT: store ptr [[A]], ptr [[A_ADDR]], align 4
296 // CHECK2-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 4
297 // CHECK2-NEXT: [[TMP1:%.*]] = call i32 @__kmpc_target_init(ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_kernel_environment, ptr [[DYN_PTR]])
298 // CHECK2-NEXT: [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP1]], -1
299 // CHECK2-NEXT: br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]]
300 // CHECK2: user_code.entry:
301 // CHECK2-NEXT: [[TMP2:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
302 // CHECK2-NEXT: [[TMP3:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
303 // CHECK2-NEXT: store i32 [[TMP3]], ptr [[ARGC_CASTED]], align 4
304 // CHECK2-NEXT: [[TMP4:%.*]] = load i32, ptr [[ARGC_CASTED]], align 4
305 // CHECK2-NEXT: store i32 0, ptr [[DOTZERO_ADDR]], align 4
306 // CHECK2-NEXT: store i32 [[TMP2]], ptr [[DOTTHREADID_TEMP_]], align 4
307 // CHECK2-NEXT: call void @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_omp_outlined(ptr [[DOTTHREADID_TEMP_]], ptr [[DOTZERO_ADDR]], i32 [[TMP4]], ptr [[TMP0]]) #[[ATTR2:[0-9]+]]
308 // CHECK2-NEXT: call void @__kmpc_target_deinit()
309 // CHECK2-NEXT: ret void
310 // CHECK2: worker.exit:
311 // CHECK2-NEXT: ret void
314 // CHECK2-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_omp_outlined
315 // CHECK2-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]], i32 noundef [[ARGC:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR1:[0-9]+]] {
316 // CHECK2-NEXT: entry:
317 // CHECK2-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 4
318 // CHECK2-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 4
319 // CHECK2-NEXT: [[ARGC_ADDR:%.*]] = alloca i32, align 4
320 // CHECK2-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 4
321 // CHECK2-NEXT: [[DOTOMP_IV:%.*]] = alloca i32, align 4
322 // CHECK2-NEXT: [[TMP:%.*]] = alloca i32, align 4
323 // CHECK2-NEXT: [[DOTCAPTURE_EXPR_:%.*]] = alloca i32, align 4
324 // CHECK2-NEXT: [[DOTCAPTURE_EXPR_1:%.*]] = alloca i32, align 4
325 // CHECK2-NEXT: [[I:%.*]] = alloca i32, align 4
326 // CHECK2-NEXT: [[DOTOMP_COMB_LB:%.*]] = alloca i32, align 4
327 // CHECK2-NEXT: [[DOTOMP_COMB_UB:%.*]] = alloca i32, align 4
328 // CHECK2-NEXT: [[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
329 // CHECK2-NEXT: [[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
330 // CHECK2-NEXT: [[I3:%.*]] = alloca i32, align 4
331 // CHECK2-NEXT: [[ARGC_CASTED:%.*]] = alloca i32, align 4
332 // CHECK2-NEXT: [[CAPTURED_VARS_ADDRS:%.*]] = alloca [4 x ptr], align 4
333 // CHECK2-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 4
334 // CHECK2-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 4
335 // CHECK2-NEXT: store i32 [[ARGC]], ptr [[ARGC_ADDR]], align 4
336 // CHECK2-NEXT: store ptr [[A]], ptr [[A_ADDR]], align 4
337 // CHECK2-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 4
338 // CHECK2-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
339 // CHECK2-NEXT: store i32 [[TMP1]], ptr [[DOTCAPTURE_EXPR_]], align 4
340 // CHECK2-NEXT: [[TMP2:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
341 // CHECK2-NEXT: [[SUB:%.*]] = sub nsw i32 [[TMP2]], 0
342 // CHECK2-NEXT: [[DIV:%.*]] = sdiv i32 [[SUB]], 1
343 // CHECK2-NEXT: [[SUB2:%.*]] = sub nsw i32 [[DIV]], 1
344 // CHECK2-NEXT: store i32 [[SUB2]], ptr [[DOTCAPTURE_EXPR_1]], align 4
345 // CHECK2-NEXT: store i32 0, ptr [[I]], align 4
346 // CHECK2-NEXT: [[TMP3:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
347 // CHECK2-NEXT: [[CMP:%.*]] = icmp slt i32 0, [[TMP3]]
348 // CHECK2-NEXT: br i1 [[CMP]], label [[OMP_PRECOND_THEN:%.*]], label [[OMP_PRECOND_END:%.*]]
349 // CHECK2: omp.precond.then:
350 // CHECK2-NEXT: store i32 0, ptr [[DOTOMP_COMB_LB]], align 4
351 // CHECK2-NEXT: [[TMP4:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
352 // CHECK2-NEXT: store i32 [[TMP4]], ptr [[DOTOMP_COMB_UB]], align 4
353 // CHECK2-NEXT: store i32 1, ptr [[DOTOMP_STRIDE]], align 4
354 // CHECK2-NEXT: store i32 0, ptr [[DOTOMP_IS_LAST]], align 4
355 // CHECK2-NEXT: [[NVPTX_NUM_THREADS:%.*]] = call i32 @__kmpc_get_hardware_num_threads_in_block()
356 // CHECK2-NEXT: [[TMP5:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 4
357 // CHECK2-NEXT: [[TMP6:%.*]] = load i32, ptr [[TMP5]], align 4
358 // CHECK2-NEXT: call void @__kmpc_distribute_static_init_4(ptr @[[GLOB2:[0-9]+]], i32 [[TMP6]], i32 91, ptr [[DOTOMP_IS_LAST]], ptr [[DOTOMP_COMB_LB]], ptr [[DOTOMP_COMB_UB]], ptr [[DOTOMP_STRIDE]], i32 1, i32 [[NVPTX_NUM_THREADS]])
359 // CHECK2-NEXT: [[TMP7:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
360 // CHECK2-NEXT: [[TMP8:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
361 // CHECK2-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[TMP7]], [[TMP8]]
362 // CHECK2-NEXT: br i1 [[CMP4]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
363 // CHECK2: cond.true:
364 // CHECK2-NEXT: [[TMP9:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
365 // CHECK2-NEXT: br label [[COND_END:%.*]]
366 // CHECK2: cond.false:
367 // CHECK2-NEXT: [[TMP10:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
368 // CHECK2-NEXT: br label [[COND_END]]
370 // CHECK2-NEXT: [[COND:%.*]] = phi i32 [ [[TMP9]], [[COND_TRUE]] ], [ [[TMP10]], [[COND_FALSE]] ]
371 // CHECK2-NEXT: store i32 [[COND]], ptr [[DOTOMP_COMB_UB]], align 4
372 // CHECK2-NEXT: [[TMP11:%.*]] = load i32, ptr [[DOTOMP_COMB_LB]], align 4
373 // CHECK2-NEXT: store i32 [[TMP11]], ptr [[DOTOMP_IV]], align 4
374 // CHECK2-NEXT: br label [[OMP_INNER_FOR_COND:%.*]]
375 // CHECK2: omp.inner.for.cond:
376 // CHECK2-NEXT: [[TMP12:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
377 // CHECK2-NEXT: [[TMP13:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
378 // CHECK2-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP13]], 1
379 // CHECK2-NEXT: [[CMP5:%.*]] = icmp slt i32 [[TMP12]], [[ADD]]
380 // CHECK2-NEXT: br i1 [[CMP5]], label [[OMP_INNER_FOR_BODY:%.*]], label [[OMP_INNER_FOR_END:%.*]]
381 // CHECK2: omp.inner.for.body:
382 // CHECK2-NEXT: [[TMP14:%.*]] = load i32, ptr [[DOTOMP_COMB_LB]], align 4
383 // CHECK2-NEXT: [[TMP15:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
384 // CHECK2-NEXT: [[TMP16:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
385 // CHECK2-NEXT: store i32 [[TMP16]], ptr [[ARGC_CASTED]], align 4
386 // CHECK2-NEXT: [[TMP17:%.*]] = load i32, ptr [[ARGC_CASTED]], align 4
387 // CHECK2-NEXT: [[TMP18:%.*]] = getelementptr inbounds [4 x ptr], ptr [[CAPTURED_VARS_ADDRS]], i32 0, i32 0
388 // CHECK2-NEXT: [[TMP19:%.*]] = inttoptr i32 [[TMP14]] to ptr
389 // CHECK2-NEXT: store ptr [[TMP19]], ptr [[TMP18]], align 4
390 // CHECK2-NEXT: [[TMP20:%.*]] = getelementptr inbounds [4 x ptr], ptr [[CAPTURED_VARS_ADDRS]], i32 0, i32 1
391 // CHECK2-NEXT: [[TMP21:%.*]] = inttoptr i32 [[TMP15]] to ptr
392 // CHECK2-NEXT: store ptr [[TMP21]], ptr [[TMP20]], align 4
393 // CHECK2-NEXT: [[TMP22:%.*]] = getelementptr inbounds [4 x ptr], ptr [[CAPTURED_VARS_ADDRS]], i32 0, i32 2
394 // CHECK2-NEXT: [[TMP23:%.*]] = inttoptr i32 [[TMP17]] to ptr
395 // CHECK2-NEXT: store ptr [[TMP23]], ptr [[TMP22]], align 4
396 // CHECK2-NEXT: [[TMP24:%.*]] = getelementptr inbounds [4 x ptr], ptr [[CAPTURED_VARS_ADDRS]], i32 0, i32 3
397 // CHECK2-NEXT: store ptr [[TMP0]], ptr [[TMP24]], align 4
398 // CHECK2-NEXT: [[TMP25:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 4
399 // CHECK2-NEXT: [[TMP26:%.*]] = load i32, ptr [[TMP25]], align 4
400 // CHECK2-NEXT: call void @__kmpc_parallel_51(ptr @[[GLOB1]], i32 [[TMP26]], i32 1, i32 -1, i32 -1, ptr @{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_omp_outlined_omp_outlined, ptr null, ptr [[CAPTURED_VARS_ADDRS]], i32 4)
401 // CHECK2-NEXT: br label [[OMP_INNER_FOR_INC:%.*]]
402 // CHECK2: omp.inner.for.inc:
403 // CHECK2-NEXT: [[TMP27:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
404 // CHECK2-NEXT: [[TMP28:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
405 // CHECK2-NEXT: [[ADD6:%.*]] = add nsw i32 [[TMP27]], [[TMP28]]
406 // CHECK2-NEXT: store i32 [[ADD6]], ptr [[DOTOMP_IV]], align 4
407 // CHECK2-NEXT: [[TMP29:%.*]] = load i32, ptr [[DOTOMP_COMB_LB]], align 4
408 // CHECK2-NEXT: [[TMP30:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
409 // CHECK2-NEXT: [[ADD7:%.*]] = add nsw i32 [[TMP29]], [[TMP30]]
410 // CHECK2-NEXT: store i32 [[ADD7]], ptr [[DOTOMP_COMB_LB]], align 4
411 // CHECK2-NEXT: [[TMP31:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
412 // CHECK2-NEXT: [[TMP32:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
413 // CHECK2-NEXT: [[ADD8:%.*]] = add nsw i32 [[TMP31]], [[TMP32]]
414 // CHECK2-NEXT: store i32 [[ADD8]], ptr [[DOTOMP_COMB_UB]], align 4
415 // CHECK2-NEXT: [[TMP33:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
416 // CHECK2-NEXT: [[TMP34:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
417 // CHECK2-NEXT: [[CMP9:%.*]] = icmp sgt i32 [[TMP33]], [[TMP34]]
418 // CHECK2-NEXT: br i1 [[CMP9]], label [[COND_TRUE10:%.*]], label [[COND_FALSE11:%.*]]
419 // CHECK2: cond.true10:
420 // CHECK2-NEXT: [[TMP35:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
421 // CHECK2-NEXT: br label [[COND_END12:%.*]]
422 // CHECK2: cond.false11:
423 // CHECK2-NEXT: [[TMP36:%.*]] = load i32, ptr [[DOTOMP_COMB_UB]], align 4
424 // CHECK2-NEXT: br label [[COND_END12]]
425 // CHECK2: cond.end12:
426 // CHECK2-NEXT: [[COND13:%.*]] = phi i32 [ [[TMP35]], [[COND_TRUE10]] ], [ [[TMP36]], [[COND_FALSE11]] ]
427 // CHECK2-NEXT: store i32 [[COND13]], ptr [[DOTOMP_COMB_UB]], align 4
428 // CHECK2-NEXT: [[TMP37:%.*]] = load i32, ptr [[DOTOMP_COMB_LB]], align 4
429 // CHECK2-NEXT: store i32 [[TMP37]], ptr [[DOTOMP_IV]], align 4
430 // CHECK2-NEXT: br label [[OMP_INNER_FOR_COND]]
431 // CHECK2: omp.inner.for.end:
432 // CHECK2-NEXT: br label [[OMP_LOOP_EXIT:%.*]]
433 // CHECK2: omp.loop.exit:
434 // CHECK2-NEXT: [[TMP38:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 4
435 // CHECK2-NEXT: [[TMP39:%.*]] = load i32, ptr [[TMP38]], align 4
436 // CHECK2-NEXT: call void @__kmpc_for_static_fini(ptr @[[GLOB3:[0-9]+]], i32 [[TMP39]])
437 // CHECK2-NEXT: br label [[OMP_PRECOND_END]]
438 // CHECK2: omp.precond.end:
439 // CHECK2-NEXT: ret void
442 // CHECK2-LABEL: define {{[^@]+}}@{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_main_l24_omp_outlined_omp_outlined
443 // CHECK2-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]], i32 noundef [[DOTPREVIOUS_LB_:%.*]], i32 noundef [[DOTPREVIOUS_UB_:%.*]], i32 noundef [[ARGC:%.*]], ptr noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR1]] {
444 // CHECK2-NEXT: entry:
445 // CHECK2-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 4
446 // CHECK2-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 4
447 // CHECK2-NEXT: [[DOTPREVIOUS_LB__ADDR:%.*]] = alloca i32, align 4
448 // CHECK2-NEXT: [[DOTPREVIOUS_UB__ADDR:%.*]] = alloca i32, align 4
449 // CHECK2-NEXT: [[ARGC_ADDR:%.*]] = alloca i32, align 4
450 // CHECK2-NEXT: [[A_ADDR:%.*]] = alloca ptr, align 4
451 // CHECK2-NEXT: [[DOTOMP_IV:%.*]] = alloca i32, align 4
452 // CHECK2-NEXT: [[TMP:%.*]] = alloca i32, align 4
453 // CHECK2-NEXT: [[DOTCAPTURE_EXPR_:%.*]] = alloca i32, align 4
454 // CHECK2-NEXT: [[DOTCAPTURE_EXPR_1:%.*]] = alloca i32, align 4
455 // CHECK2-NEXT: [[I:%.*]] = alloca i32, align 4
456 // CHECK2-NEXT: [[DOTOMP_LB:%.*]] = alloca i32, align 4
457 // CHECK2-NEXT: [[DOTOMP_UB:%.*]] = alloca i32, align 4
458 // CHECK2-NEXT: [[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
459 // CHECK2-NEXT: [[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
460 // CHECK2-NEXT: [[I3:%.*]] = alloca i32, align 4
461 // CHECK2-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 4
462 // CHECK2-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 4
463 // CHECK2-NEXT: store i32 [[DOTPREVIOUS_LB_]], ptr [[DOTPREVIOUS_LB__ADDR]], align 4
464 // CHECK2-NEXT: store i32 [[DOTPREVIOUS_UB_]], ptr [[DOTPREVIOUS_UB__ADDR]], align 4
465 // CHECK2-NEXT: store i32 [[ARGC]], ptr [[ARGC_ADDR]], align 4
466 // CHECK2-NEXT: store ptr [[A]], ptr [[A_ADDR]], align 4
467 // CHECK2-NEXT: [[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 4
468 // CHECK2-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARGC_ADDR]], align 4
469 // CHECK2-NEXT: store i32 [[TMP1]], ptr [[DOTCAPTURE_EXPR_]], align 4
470 // CHECK2-NEXT: [[TMP2:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
471 // CHECK2-NEXT: [[SUB:%.*]] = sub nsw i32 [[TMP2]], 0
472 // CHECK2-NEXT: [[DIV:%.*]] = sdiv i32 [[SUB]], 1
473 // CHECK2-NEXT: [[SUB2:%.*]] = sub nsw i32 [[DIV]], 1
474 // CHECK2-NEXT: store i32 [[SUB2]], ptr [[DOTCAPTURE_EXPR_1]], align 4
475 // CHECK2-NEXT: store i32 0, ptr [[I]], align 4
476 // CHECK2-NEXT: [[TMP3:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_]], align 4
477 // CHECK2-NEXT: [[CMP:%.*]] = icmp slt i32 0, [[TMP3]]
478 // CHECK2-NEXT: br i1 [[CMP]], label [[OMP_PRECOND_THEN:%.*]], label [[OMP_PRECOND_END:%.*]]
479 // CHECK2: omp.precond.then:
480 // CHECK2-NEXT: store i32 0, ptr [[DOTOMP_LB]], align 4
481 // CHECK2-NEXT: [[TMP4:%.*]] = load i32, ptr [[DOTCAPTURE_EXPR_1]], align 4
482 // CHECK2-NEXT: store i32 [[TMP4]], ptr [[DOTOMP_UB]], align 4
483 // CHECK2-NEXT: [[TMP5:%.*]] = load i32, ptr [[DOTPREVIOUS_LB__ADDR]], align 4
484 // CHECK2-NEXT: [[TMP6:%.*]] = load i32, ptr [[DOTPREVIOUS_UB__ADDR]], align 4
485 // CHECK2-NEXT: store i32 [[TMP5]], ptr [[DOTOMP_LB]], align 4
486 // CHECK2-NEXT: store i32 [[TMP6]], ptr [[DOTOMP_UB]], align 4
487 // CHECK2-NEXT: store i32 1, ptr [[DOTOMP_STRIDE]], align 4
488 // CHECK2-NEXT: store i32 0, ptr [[DOTOMP_IS_LAST]], align 4
489 // CHECK2-NEXT: [[TMP7:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 4
490 // CHECK2-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP7]], align 4
491 // CHECK2-NEXT: call void @__kmpc_for_static_init_4(ptr @[[GLOB3]], i32 [[TMP8]], i32 33, ptr [[DOTOMP_IS_LAST]], ptr [[DOTOMP_LB]], ptr [[DOTOMP_UB]], ptr [[DOTOMP_STRIDE]], i32 1, i32 1)
492 // CHECK2-NEXT: [[TMP9:%.*]] = load i32, ptr [[DOTOMP_LB]], align 4
493 // CHECK2-NEXT: store i32 [[TMP9]], ptr [[DOTOMP_IV]], align 4
494 // CHECK2-NEXT: br label [[OMP_INNER_FOR_COND:%.*]]
495 // CHECK2: omp.inner.for.cond:
496 // CHECK2-NEXT: [[TMP10:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
497 // CHECK2-NEXT: [[TMP11:%.*]] = load i32, ptr [[DOTPREVIOUS_UB__ADDR]], align 4
498 // CHECK2-NEXT: [[CMP4:%.*]] = icmp ule i32 [[TMP10]], [[TMP11]]
499 // CHECK2-NEXT: br i1 [[CMP4]], label [[OMP_INNER_FOR_BODY:%.*]], label [[OMP_INNER_FOR_END:%.*]]
500 // CHECK2: omp.inner.for.body:
501 // CHECK2-NEXT: [[TMP12:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
502 // CHECK2-NEXT: [[MUL:%.*]] = mul nsw i32 [[TMP12]], 1
503 // CHECK2-NEXT: [[ADD:%.*]] = add nsw i32 0, [[MUL]]
504 // CHECK2-NEXT: store i32 [[ADD]], ptr [[I3]], align 4
505 // CHECK2-NEXT: [[CALL:%.*]] = call noundef i32 @_Z3fooPi(ptr noundef [[I3]]) #[[ATTR5:[0-9]+]]
506 // CHECK2-NEXT: [[CALL5:%.*]] = call noundef i32 @_Z3fooPi(ptr noundef [[TMP0]]) #[[ATTR5]]
507 // CHECK2-NEXT: [[ADD6:%.*]] = add nsw i32 [[CALL]], [[CALL5]]
508 // CHECK2-NEXT: [[CALL7:%.*]] = call noundef i32 @_Z3fooPi(ptr noundef [[ARGC_ADDR]]) #[[ATTR5]]
509 // CHECK2-NEXT: [[ADD8:%.*]] = add nsw i32 [[ADD6]], [[CALL7]]
510 // CHECK2-NEXT: store i32 [[ADD8]], ptr [[TMP0]], align 4
511 // CHECK2-NEXT: br label [[OMP_BODY_CONTINUE:%.*]]
512 // CHECK2: omp.body.continue:
513 // CHECK2-NEXT: br label [[OMP_INNER_FOR_INC:%.*]]
514 // CHECK2: omp.inner.for.inc:
515 // CHECK2-NEXT: [[TMP13:%.*]] = load i32, ptr [[DOTOMP_IV]], align 4
516 // CHECK2-NEXT: [[TMP14:%.*]] = load i32, ptr [[DOTOMP_STRIDE]], align 4
517 // CHECK2-NEXT: [[ADD9:%.*]] = add nsw i32 [[TMP13]], [[TMP14]]
518 // CHECK2-NEXT: store i32 [[ADD9]], ptr [[DOTOMP_IV]], align 4
519 // CHECK2-NEXT: br label [[OMP_INNER_FOR_COND]]
520 // CHECK2: omp.inner.for.end:
521 // CHECK2-NEXT: br label [[OMP_LOOP_EXIT:%.*]]
522 // CHECK2: omp.loop.exit:
523 // CHECK2-NEXT: [[TMP15:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 4
524 // CHECK2-NEXT: [[TMP16:%.*]] = load i32, ptr [[TMP15]], align 4
525 // CHECK2-NEXT: call void @__kmpc_for_static_fini(ptr @[[GLOB3]], i32 [[TMP16]])
526 // CHECK2-NEXT: br label [[OMP_PRECOND_END]]
527 // CHECK2: omp.precond.end:
528 // CHECK2-NEXT: ret void