1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
2; RUN: opt -S -passes=openmp-opt < %s | FileCheck %s
3; RUN: opt -S -passes=openmp-opt -openmp-opt-disable-spmdization < %s | FileCheck %s --check-prefix=CHECK-DISABLED
4;
5;    void pure(void) __attribute__((pure, assume("ompx_spmd_amenable")));
6;    int no_openmp(int *) __attribute__((assume("omp_no_openmp","ompx_spmd_amenable")));
7;
8;    void sequential_loop(int *x, int N) {
9;    #pragma omp target teams
10;      {
11;        x[0] = 0;
12;        x[1] = 1;
13;        x[N] = N;
14;        for (int i = 2; i < N - 1; ++i)
15;          x[i] = i - 1;
16;        #pragma omp parallel
17;        {}
18;        int r1 = no_openmp(x);
19;        x[r1] = r1;
20;        int r2 = no_openmp(x);
21;        x[r2] = r2;
22;        int r3 = no_openmp(x);
23;        x[r3] = r3;
24;
25;        no_openmp(x);
26;        pure();
27;        no_openmp(x);
28;        pure();
29;        no_openmp(x);
30;        pure();
31;      }
32;    }
33;
34target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
35target triple = "nvptx64"
36
37%struct.ident_t = type { i32, i32, i32, i32, i8* }
38
39@0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1
40@1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @0, i32 0, i32 0) }, align 8
41@__omp_offloading_2a_fbfa7a_sequential_loop_l6_exec_mode = weak constant i8 1
42@llvm.compiler.used = appending global [1 x i8*] [i8* @__omp_offloading_2a_fbfa7a_sequential_loop_l6_exec_mode], section "llvm.metadata"
43
44; Function Attrs: convergent norecurse nounwind
45;.
46; CHECK: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [23 x i8] c"
47; CHECK: @[[GLOB1:[0-9]+]] = private unnamed_addr constant [[STRUCT_IDENT_T:%.*]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @[[GLOB0]], i32 0, i32 0) }, align 8
48; CHECK: @[[__OMP_OFFLOADING_2A_FBFA7A_SEQUENTIAL_LOOP_L6_EXEC_MODE:[a-zA-Z0-9_$"\\.-]+]] = weak constant i8 3
49; CHECK: @[[LLVM_COMPILER_USED:[a-zA-Z0-9_$"\\.-]+]] = appending global [1 x i8*] [i8* @__omp_offloading_2a_fbfa7a_sequential_loop_l6_exec_mode], section "llvm.metadata"
50; CHECK: @[[GLOB2:[0-9]+]] = private unnamed_addr constant [[STRUCT_IDENT_T:%.*]] { i32 0, i32 2, i32 0, i32 22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @[[GLOB0]], i32 0, i32 0) }, align 8
51;.
52; CHECK-DISABLED: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [23 x i8] c"
53; CHECK-DISABLED: @[[GLOB1:[0-9]+]] = private unnamed_addr constant [[STRUCT_IDENT_T:%.*]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @[[GLOB0]], i32 0, i32 0) }, align 8
54; CHECK-DISABLED: @[[__OMP_OFFLOADING_2A_FBFA7A_SEQUENTIAL_LOOP_L6_EXEC_MODE:[a-zA-Z0-9_$"\\.-]+]] = weak constant i8 1
55; CHECK-DISABLED: @[[LLVM_COMPILER_USED:[a-zA-Z0-9_$"\\.-]+]] = appending global [1 x i8*] [i8* @__omp_offloading_2a_fbfa7a_sequential_loop_l6_exec_mode], section "llvm.metadata"
56; CHECK-DISABLED: @[[__OMP_OUTLINED__1_WRAPPER_ID:[a-zA-Z0-9_$"\\.-]+]] = private constant i8 undef
57;.
58define weak void @__omp_offloading_2a_fbfa7a_sequential_loop_l6(i32* %x, i64 %N) #0 {
59; CHECK-LABEL: define {{[^@]+}}@__omp_offloading_2a_fbfa7a_sequential_loop_l6
60; CHECK-SAME: (i32* [[X:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
61; CHECK-NEXT:  entry:
62; CHECK-NEXT:    [[HEAP2STACK_H2S:%.*]] = alloca i8, i64 8, align 8
63; CHECK-NEXT:    [[N_ADDR_SROA_0_0_EXTRACT_TRUNC:%.*]] = trunc i64 [[N]] to i32
64; CHECK-NEXT:    [[TMP0:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @[[GLOB1]], i8 2, i1 false, i1 false) #[[ATTR6:[0-9]+]]
65; CHECK-NEXT:    [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1
66; CHECK-NEXT:    br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]]
67; CHECK:       user_code.entry:
68; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* nonnull @[[GLOB1]]) #[[ATTR6]]
69; CHECK-NEXT:    [[ARRAYIDX1_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 1
70; CHECK-NEXT:    [[SEXT:%.*]] = shl i64 [[N]], 32
71; CHECK-NEXT:    [[IDXPROM_I:%.*]] = ashr exact i64 [[SEXT]], 32
72; CHECK-NEXT:    [[ARRAYIDX2_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM_I]]
73; CHECK-NEXT:    br label [[REGION_CHECK_TID:%.*]]
74; CHECK:       region.check.tid:
75; CHECK-NEXT:    [[TMP2:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block()
76; CHECK-NEXT:    [[TMP3:%.*]] = icmp eq i32 [[TMP2]], 0
77; CHECK-NEXT:    br i1 [[TMP3]], label [[REGION_GUARDED:%.*]], label [[REGION_BARRIER:%.*]]
78; CHECK:       region.guarded:
79; CHECK-NEXT:    store i32 0, i32* [[X]], align 4, !noalias !8
80; CHECK-NEXT:    store i32 1, i32* [[ARRAYIDX1_I]], align 4, !noalias !8
81; CHECK-NEXT:    store i32 [[N_ADDR_SROA_0_0_EXTRACT_TRUNC]], i32* [[ARRAYIDX2_I]], align 4, !noalias !8
82; CHECK-NEXT:    br label [[REGION_GUARDED_END:%.*]]
83; CHECK:       region.guarded.end:
84; CHECK-NEXT:    br label [[REGION_BARRIER]]
85; CHECK:       region.barrier:
86; CHECK-NEXT:    call void @__kmpc_barrier_simple_spmd(%struct.ident_t* @[[GLOB2]], i32 [[TMP2]])
87; CHECK-NEXT:    br label [[REGION_EXIT:%.*]]
88; CHECK:       region.exit:
89; CHECK-NEXT:    call void @usei8ptr(i8* nocapture [[HEAP2STACK_H2S]]) #[[ATTR9:[0-9]+]]
90; CHECK-NEXT:    br label [[FOR_COND_I:%.*]]
91; CHECK:       for.cond.i:
92; CHECK-NEXT:    [[I_0_I:%.*]] = phi i32 [ 2, [[REGION_EXIT]] ], [ [[INC_I:%.*]], [[REGION_EXIT3:%.*]] ]
93; CHECK-NEXT:    [[SUB_I:%.*]] = add nsw i32 [[N_ADDR_SROA_0_0_EXTRACT_TRUNC]], -1
94; CHECK-NEXT:    [[CMP_I:%.*]] = icmp slt i32 [[I_0_I]], [[SUB_I]]
95; CHECK-NEXT:    br i1 [[CMP_I]], label [[FOR_BODY_I:%.*]], label [[__OMP_OUTLINED___EXIT:%.*]]
96; CHECK:       for.body.i:
97; CHECK-NEXT:    [[SUB3_I:%.*]] = add nsw i32 [[I_0_I]], -1
98; CHECK-NEXT:    [[IDXPROM4_I:%.*]] = zext i32 [[I_0_I]] to i64
99; CHECK-NEXT:    [[ARRAYIDX5_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM4_I]]
100; CHECK-NEXT:    br label [[REGION_CHECK_TID5:%.*]]
101; CHECK:       region.check.tid5:
102; CHECK-NEXT:    [[TMP4:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block()
103; CHECK-NEXT:    [[TMP5:%.*]] = icmp eq i32 [[TMP4]], 0
104; CHECK-NEXT:    br i1 [[TMP5]], label [[REGION_GUARDED4:%.*]], label [[REGION_BARRIER2:%.*]]
105; CHECK:       region.guarded4:
106; CHECK-NEXT:    store i32 [[SUB3_I]], i32* [[ARRAYIDX5_I]], align 4, !noalias !8
107; CHECK-NEXT:    br label [[REGION_GUARDED_END1:%.*]]
108; CHECK:       region.guarded.end1:
109; CHECK-NEXT:    br label [[REGION_BARRIER2]]
110; CHECK:       region.barrier2:
111; CHECK-NEXT:    call void @__kmpc_barrier_simple_spmd(%struct.ident_t* @[[GLOB2]], i32 [[TMP4]])
112; CHECK-NEXT:    br label [[REGION_EXIT3]]
113; CHECK:       region.exit3:
114; CHECK-NEXT:    [[INC_I]] = add nuw nsw i32 [[I_0_I]], 1
115; CHECK-NEXT:    br label [[FOR_COND_I]], !llvm.loop [[LOOP11:![0-9]+]]
116; CHECK:       __omp_outlined__.exit:
117; CHECK-NEXT:    call void @__kmpc_parallel_51(%struct.ident_t* null, i32 0, i32 1, i32 -1, i32 -1, i8* bitcast (void (i32*, i32*)* @__omp_outlined__1 to i8*), i8* bitcast (void (i16, i32)* @__omp_outlined__1_wrapper to i8*), i8** null, i64 0)
118; CHECK-NEXT:    [[CALL_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10:[0-9]+]], !noalias !8
119; CHECK-NEXT:    [[IDXPROM6_I:%.*]] = sext i32 [[CALL_I]] to i64
120; CHECK-NEXT:    [[ARRAYIDX7_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM6_I]]
121; CHECK-NEXT:    br label [[REGION_CHECK_TID10:%.*]]
122; CHECK:       region.check.tid10:
123; CHECK-NEXT:    [[TMP6:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block()
124; CHECK-NEXT:    [[TMP7:%.*]] = icmp eq i32 [[TMP6]], 0
125; CHECK-NEXT:    br i1 [[TMP7]], label [[REGION_GUARDED9:%.*]], label [[REGION_BARRIER7:%.*]]
126; CHECK:       region.guarded9:
127; CHECK-NEXT:    store i32 [[CALL_I]], i32* [[ARRAYIDX7_I]], align 4, !noalias !8
128; CHECK-NEXT:    br label [[REGION_GUARDED_END6:%.*]]
129; CHECK:       region.guarded.end6:
130; CHECK-NEXT:    br label [[REGION_BARRIER7]]
131; CHECK:       region.barrier7:
132; CHECK-NEXT:    call void @__kmpc_barrier_simple_spmd(%struct.ident_t* @[[GLOB2]], i32 [[TMP6]])
133; CHECK-NEXT:    br label [[REGION_EXIT8:%.*]]
134; CHECK:       region.exit8:
135; CHECK-NEXT:    [[CALL8_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
136; CHECK-NEXT:    [[IDXPROM9_I:%.*]] = sext i32 [[CALL8_I]] to i64
137; CHECK-NEXT:    [[ARRAYIDX10_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM9_I]]
138; CHECK-NEXT:    br label [[REGION_CHECK_TID15:%.*]]
139; CHECK:       region.check.tid15:
140; CHECK-NEXT:    [[TMP8:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block()
141; CHECK-NEXT:    [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 0
142; CHECK-NEXT:    br i1 [[TMP9]], label [[REGION_GUARDED14:%.*]], label [[REGION_BARRIER12:%.*]]
143; CHECK:       region.guarded14:
144; CHECK-NEXT:    store i32 [[CALL8_I]], i32* [[ARRAYIDX10_I]], align 4, !noalias !8
145; CHECK-NEXT:    br label [[REGION_GUARDED_END11:%.*]]
146; CHECK:       region.guarded.end11:
147; CHECK-NEXT:    br label [[REGION_BARRIER12]]
148; CHECK:       region.barrier12:
149; CHECK-NEXT:    call void @__kmpc_barrier_simple_spmd(%struct.ident_t* @[[GLOB2]], i32 [[TMP8]])
150; CHECK-NEXT:    br label [[REGION_EXIT13:%.*]]
151; CHECK:       region.exit13:
152; CHECK-NEXT:    [[CALL11_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
153; CHECK-NEXT:    [[IDXPROM12_I:%.*]] = sext i32 [[CALL11_I]] to i64
154; CHECK-NEXT:    [[ARRAYIDX13_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM12_I]]
155; CHECK-NEXT:    br label [[REGION_CHECK_TID20:%.*]]
156; CHECK:       region.check.tid20:
157; CHECK-NEXT:    [[TMP10:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block()
158; CHECK-NEXT:    [[TMP11:%.*]] = icmp eq i32 [[TMP10]], 0
159; CHECK-NEXT:    br i1 [[TMP11]], label [[REGION_GUARDED19:%.*]], label [[REGION_BARRIER17:%.*]]
160; CHECK:       region.guarded19:
161; CHECK-NEXT:    store i32 [[CALL11_I]], i32* [[ARRAYIDX13_I]], align 4, !noalias !8
162; CHECK-NEXT:    br label [[REGION_GUARDED_END16:%.*]]
163; CHECK:       region.guarded.end16:
164; CHECK-NEXT:    br label [[REGION_BARRIER17]]
165; CHECK:       region.barrier17:
166; CHECK-NEXT:    call void @__kmpc_barrier_simple_spmd(%struct.ident_t* @[[GLOB2]], i32 [[TMP10]])
167; CHECK-NEXT:    br label [[REGION_EXIT18:%.*]]
168; CHECK:       region.exit18:
169; CHECK-NEXT:    [[CALL14_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
170; CHECK-NEXT:    [[CALL15_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
171; CHECK-NEXT:    [[CALL16_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
172; CHECK-NEXT:    call void @__kmpc_target_deinit(%struct.ident_t* nonnull @[[GLOB1]], i8 2, i1 false) #[[ATTR6]]
173; CHECK-NEXT:    ret void
174; CHECK:       worker.exit:
175; CHECK-NEXT:    ret void
176;
177; CHECK-DISABLED-LABEL: define {{[^@]+}}@__omp_offloading_2a_fbfa7a_sequential_loop_l6
178; CHECK-DISABLED-SAME: (i32* [[X:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
179; CHECK-DISABLED-NEXT:  entry:
180; CHECK-DISABLED-NEXT:    [[HEAP2STACK_H2S:%.*]] = alloca i8, i64 8, align 8
181; CHECK-DISABLED-NEXT:    [[WORKER_WORK_FN_ADDR:%.*]] = alloca i8*, align 8
182; CHECK-DISABLED-NEXT:    [[N_ADDR_SROA_0_0_EXTRACT_TRUNC:%.*]] = trunc i64 [[N]] to i32
183; CHECK-DISABLED-NEXT:    [[TMP0:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @[[GLOB1]], i8 1, i1 false, i1 true) #[[ATTR6:[0-9]+]]
184; CHECK-DISABLED-NEXT:    [[THREAD_IS_WORKER:%.*]] = icmp ne i32 [[TMP0]], -1
185; CHECK-DISABLED-NEXT:    br i1 [[THREAD_IS_WORKER]], label [[IS_WORKER_CHECK:%.*]], label [[THREAD_USER_CODE_CHECK:%.*]]
186; CHECK-DISABLED:       is_worker_check:
187; CHECK-DISABLED-NEXT:    [[BLOCK_HW_SIZE:%.*]] = call i32 @__kmpc_get_hardware_num_threads_in_block()
188; CHECK-DISABLED-NEXT:    [[WARP_SIZE:%.*]] = call i32 @__kmpc_get_warp_size()
189; CHECK-DISABLED-NEXT:    [[BLOCK_SIZE:%.*]] = sub i32 [[BLOCK_HW_SIZE]], [[WARP_SIZE]]
190; CHECK-DISABLED-NEXT:    [[THREAD_IS_MAIN_OR_WORKER:%.*]] = icmp slt i32 [[TMP0]], [[BLOCK_SIZE]]
191; CHECK-DISABLED-NEXT:    br i1 [[THREAD_IS_MAIN_OR_WORKER]], label [[WORKER_STATE_MACHINE_BEGIN:%.*]], label [[WORKER_STATE_MACHINE_FINISHED:%.*]]
192; CHECK-DISABLED:       worker_state_machine.begin:
193; CHECK-DISABLED-NEXT:    call void @__kmpc_barrier_simple_generic(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]])
194; CHECK-DISABLED-NEXT:    [[WORKER_IS_ACTIVE:%.*]] = call i1 @__kmpc_kernel_parallel(i8** [[WORKER_WORK_FN_ADDR]])
195; CHECK-DISABLED-NEXT:    [[WORKER_WORK_FN:%.*]] = load i8*, i8** [[WORKER_WORK_FN_ADDR]], align 8
196; CHECK-DISABLED-NEXT:    [[WORKER_WORK_FN_ADDR_CAST:%.*]] = bitcast i8* [[WORKER_WORK_FN]] to void (i16, i32)*
197; CHECK-DISABLED-NEXT:    [[WORKER_IS_DONE:%.*]] = icmp eq i8* [[WORKER_WORK_FN]], null
198; CHECK-DISABLED-NEXT:    br i1 [[WORKER_IS_DONE]], label [[WORKER_STATE_MACHINE_FINISHED]], label [[WORKER_STATE_MACHINE_IS_ACTIVE_CHECK:%.*]]
199; CHECK-DISABLED:       worker_state_machine.finished:
200; CHECK-DISABLED-NEXT:    ret void
201; CHECK-DISABLED:       worker_state_machine.is_active.check:
202; CHECK-DISABLED-NEXT:    br i1 [[WORKER_IS_ACTIVE]], label [[WORKER_STATE_MACHINE_PARALLEL_REGION_CHECK:%.*]], label [[WORKER_STATE_MACHINE_DONE_BARRIER:%.*]]
203; CHECK-DISABLED:       worker_state_machine.parallel_region.check:
204; CHECK-DISABLED-NEXT:    br i1 true, label [[WORKER_STATE_MACHINE_PARALLEL_REGION_EXECUTE:%.*]], label [[WORKER_STATE_MACHINE_PARALLEL_REGION_CHECK1:%.*]]
205; CHECK-DISABLED:       worker_state_machine.parallel_region.execute:
206; CHECK-DISABLED-NEXT:    call void @__omp_outlined__1_wrapper(i16 0, i32 [[TMP0]])
207; CHECK-DISABLED-NEXT:    br label [[WORKER_STATE_MACHINE_PARALLEL_REGION_END:%.*]]
208; CHECK-DISABLED:       worker_state_machine.parallel_region.check1:
209; CHECK-DISABLED-NEXT:    br label [[WORKER_STATE_MACHINE_PARALLEL_REGION_END]]
210; CHECK-DISABLED:       worker_state_machine.parallel_region.end:
211; CHECK-DISABLED-NEXT:    call void @__kmpc_kernel_end_parallel()
212; CHECK-DISABLED-NEXT:    br label [[WORKER_STATE_MACHINE_DONE_BARRIER]]
213; CHECK-DISABLED:       worker_state_machine.done.barrier:
214; CHECK-DISABLED-NEXT:    call void @__kmpc_barrier_simple_generic(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]])
215; CHECK-DISABLED-NEXT:    br label [[WORKER_STATE_MACHINE_BEGIN]]
216; CHECK-DISABLED:       thread.user_code.check:
217; CHECK-DISABLED-NEXT:    [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1
218; CHECK-DISABLED-NEXT:    br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]]
219; CHECK-DISABLED:       user_code.entry:
220; CHECK-DISABLED-NEXT:    [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* nonnull @[[GLOB1]]) #[[ATTR6]]
221; CHECK-DISABLED-NEXT:    store i32 0, i32* [[X]], align 4, !noalias !8
222; CHECK-DISABLED-NEXT:    [[ARRAYIDX1_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 1
223; CHECK-DISABLED-NEXT:    store i32 1, i32* [[ARRAYIDX1_I]], align 4, !noalias !8
224; CHECK-DISABLED-NEXT:    [[SEXT:%.*]] = shl i64 [[N]], 32
225; CHECK-DISABLED-NEXT:    [[IDXPROM_I:%.*]] = ashr exact i64 [[SEXT]], 32
226; CHECK-DISABLED-NEXT:    [[ARRAYIDX2_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM_I]]
227; CHECK-DISABLED-NEXT:    store i32 [[N_ADDR_SROA_0_0_EXTRACT_TRUNC]], i32* [[ARRAYIDX2_I]], align 4, !noalias !8
228; CHECK-DISABLED-NEXT:    call void @usei8ptr(i8* nocapture [[HEAP2STACK_H2S]]) #[[ATTR9:[0-9]+]]
229; CHECK-DISABLED-NEXT:    br label [[FOR_COND_I:%.*]]
230; CHECK-DISABLED:       for.cond.i:
231; CHECK-DISABLED-NEXT:    [[I_0_I:%.*]] = phi i32 [ 2, [[USER_CODE_ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY_I:%.*]] ]
232; CHECK-DISABLED-NEXT:    [[SUB_I:%.*]] = add nsw i32 [[N_ADDR_SROA_0_0_EXTRACT_TRUNC]], -1
233; CHECK-DISABLED-NEXT:    [[CMP_I:%.*]] = icmp slt i32 [[I_0_I]], [[SUB_I]]
234; CHECK-DISABLED-NEXT:    br i1 [[CMP_I]], label [[FOR_BODY_I]], label [[__OMP_OUTLINED___EXIT:%.*]]
235; CHECK-DISABLED:       for.body.i:
236; CHECK-DISABLED-NEXT:    [[SUB3_I:%.*]] = add nsw i32 [[I_0_I]], -1
237; CHECK-DISABLED-NEXT:    [[IDXPROM4_I:%.*]] = zext i32 [[I_0_I]] to i64
238; CHECK-DISABLED-NEXT:    [[ARRAYIDX5_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM4_I]]
239; CHECK-DISABLED-NEXT:    store i32 [[SUB3_I]], i32* [[ARRAYIDX5_I]], align 4, !noalias !8
240; CHECK-DISABLED-NEXT:    [[INC_I]] = add nuw nsw i32 [[I_0_I]], 1
241; CHECK-DISABLED-NEXT:    br label [[FOR_COND_I]], !llvm.loop [[LOOP11:![0-9]+]]
242; CHECK-DISABLED:       __omp_outlined__.exit:
243; CHECK-DISABLED-NEXT:    call void @__kmpc_parallel_51(%struct.ident_t* null, i32 0, i32 1, i32 -1, i32 -1, i8* bitcast (void (i32*, i32*)* @__omp_outlined__1 to i8*), i8* @__omp_outlined__1_wrapper.ID, i8** null, i64 0)
244; CHECK-DISABLED-NEXT:    [[CALL_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10:[0-9]+]], !noalias !8
245; CHECK-DISABLED-NEXT:    [[IDXPROM6_I:%.*]] = sext i32 [[CALL_I]] to i64
246; CHECK-DISABLED-NEXT:    [[ARRAYIDX7_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM6_I]]
247; CHECK-DISABLED-NEXT:    store i32 [[CALL_I]], i32* [[ARRAYIDX7_I]], align 4, !noalias !8
248; CHECK-DISABLED-NEXT:    [[CALL8_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
249; CHECK-DISABLED-NEXT:    [[IDXPROM9_I:%.*]] = sext i32 [[CALL8_I]] to i64
250; CHECK-DISABLED-NEXT:    [[ARRAYIDX10_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM9_I]]
251; CHECK-DISABLED-NEXT:    store i32 [[CALL8_I]], i32* [[ARRAYIDX10_I]], align 4, !noalias !8
252; CHECK-DISABLED-NEXT:    [[CALL11_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
253; CHECK-DISABLED-NEXT:    [[IDXPROM12_I:%.*]] = sext i32 [[CALL11_I]] to i64
254; CHECK-DISABLED-NEXT:    [[ARRAYIDX13_I:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[IDXPROM12_I]]
255; CHECK-DISABLED-NEXT:    store i32 [[CALL11_I]], i32* [[ARRAYIDX13_I]], align 4, !noalias !8
256; CHECK-DISABLED-NEXT:    [[CALL14_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
257; CHECK-DISABLED-NEXT:    [[CALL15_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
258; CHECK-DISABLED-NEXT:    [[CALL16_I:%.*]] = call i32 @no_openmp(i32* nonnull [[X]]) #[[ATTR10]], !noalias !8
259; CHECK-DISABLED-NEXT:    call void @__kmpc_target_deinit(%struct.ident_t* nonnull @[[GLOB1]], i8 1, i1 true) #[[ATTR6]]
260; CHECK-DISABLED-NEXT:    ret void
261; CHECK-DISABLED:       worker.exit:
262; CHECK-DISABLED-NEXT:    ret void
263;
264entry:
265  %N.addr.sroa.0.0.extract.trunc = trunc i64 %N to i32
266  %0 = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @1, i8 1, i1 true, i1 true) #3
267  %exec_user_code = icmp eq i32 %0, -1
268  br i1 %exec_user_code, label %user_code.entry, label %worker.exit
269
270user_code.entry:                                  ; preds = %entry
271  %1 = call i32 @__kmpc_global_thread_num(%struct.ident_t* nonnull @1)
272  store i32 0, i32* %x, align 4, !noalias !8
273  %arrayidx1.i = getelementptr inbounds i32, i32* %x, i64 1
274  store i32 1, i32* %arrayidx1.i, align 4, !noalias !8
275  %sext = shl i64 %N, 32
276  %idxprom.i = ashr exact i64 %sext, 32
277  %arrayidx2.i = getelementptr inbounds i32, i32* %x, i64 %idxprom.i
278  store i32 %N.addr.sroa.0.0.extract.trunc, i32* %arrayidx2.i, align 4, !noalias !8
279  %heap2stack = call align 8 i8* @__kmpc_alloc_shared(i64 8)
280  call void @usei8ptr(i8* nocapture %heap2stack) willreturn nounwind
281  call void @__kmpc_free_shared(i8* %heap2stack, i64 8)
282  br label %for.cond.i
283
284for.cond.i:                                       ; preds = %for.body.i, %user_code.entry
285  %i.0.i = phi i32 [ 2, %user_code.entry ], [ %inc.i, %for.body.i ]
286  %sub.i = add nsw i32 %N.addr.sroa.0.0.extract.trunc, -1
287  %cmp.i = icmp slt i32 %i.0.i, %sub.i
288  br i1 %cmp.i, label %for.body.i, label %__omp_outlined__.exit
289
290for.body.i:                                       ; preds = %for.cond.i
291  %sub3.i = add nsw i32 %i.0.i, -1
292  %idxprom4.i = zext i32 %i.0.i to i64
293  %arrayidx5.i = getelementptr inbounds i32, i32* %x, i64 %idxprom4.i
294  store i32 %sub3.i, i32* %arrayidx5.i, align 4, !noalias !8
295  %inc.i = add nuw nsw i32 %i.0.i, 1
296  br label %for.cond.i, !llvm.loop !11
297
298__omp_outlined__.exit:                            ; preds = %for.cond.i
299  call void @__kmpc_parallel_51(%struct.ident_t* null, i32 0, i32 1, i32 -1, i32 -1, i8* bitcast (void (i32*, i32*)* @__omp_outlined__1 to i8*), i8* bitcast (void (i16, i32)* @__omp_outlined__1_wrapper to i8*), i8** null, i64 0)
300  %call.i = call i32 @no_openmp(i32* nonnull %x) #5, !noalias !8
301  %idxprom6.i = sext i32 %call.i to i64
302  %arrayidx7.i = getelementptr inbounds i32, i32* %x, i64 %idxprom6.i
303  store i32 %call.i, i32* %arrayidx7.i, align 4, !noalias !8
304  %call8.i = call i32 @no_openmp(i32* nonnull %x) #5, !noalias !8
305  %idxprom9.i = sext i32 %call8.i to i64
306  %arrayidx10.i = getelementptr inbounds i32, i32* %x, i64 %idxprom9.i
307  store i32 %call8.i, i32* %arrayidx10.i, align 4, !noalias !8
308  %call11.i = call i32 @no_openmp(i32* nonnull %x) #5, !noalias !8
309  %idxprom12.i = sext i32 %call11.i to i64
310  %arrayidx13.i = getelementptr inbounds i32, i32* %x, i64 %idxprom12.i
311  store i32 %call11.i, i32* %arrayidx13.i, align 4, !noalias !8
312  %call14.i = call i32 @no_openmp(i32* nonnull %x) #5, !noalias !8
313  %call15.i = call i32 @no_openmp(i32* nonnull %x) #5, !noalias !8
314  %call16.i = call i32 @no_openmp(i32* nonnull %x) #5, !noalias !8
315  call void @__kmpc_target_deinit(%struct.ident_t* nonnull @1, i8 1, i1 true) #3
316  ret void
317
318worker.exit:                                      ; preds = %entry
319  ret void
320}
321
322define internal void @__omp_outlined__1(i32* noalias %.global_tid., i32* noalias %.bound_tid.) {
323; CHECK-LABEL: define {{[^@]+}}@__omp_outlined__1
324; CHECK-SAME: (i32* noalias [[DOTGLOBAL_TID_:%.*]], i32* noalias [[DOTBOUND_TID_:%.*]]) {
325; CHECK-NEXT:    ret void
326;
327; CHECK-DISABLED-LABEL: define {{[^@]+}}@__omp_outlined__1
328; CHECK-DISABLED-SAME: (i32* noalias [[DOTGLOBAL_TID_:%.*]], i32* noalias [[DOTBOUND_TID_:%.*]]) {
329; CHECK-DISABLED-NEXT:    ret void
330;
331  ret void
332}
333define internal void @__omp_outlined__1_wrapper(i16 zeroext %0, i32 %1) {
334; CHECK-LABEL: define {{[^@]+}}@__omp_outlined__1_wrapper
335; CHECK-SAME: (i16 zeroext [[TMP0:%.*]], i32 [[TMP1:%.*]]) {
336; CHECK-NEXT:    ret void
337;
338; CHECK-DISABLED-LABEL: define {{[^@]+}}@__omp_outlined__1_wrapper
339; CHECK-DISABLED-SAME: (i16 zeroext [[TMP0:%.*]], i32 [[TMP1:%.*]]) {
340; CHECK-DISABLED-NEXT:    ret void
341;
342  ret void
343}
344
345declare void @__kmpc_parallel_51(%struct.ident_t*, i32, i32, i32, i32, i8*, i8*, i8**, i64)
346
347declare i32 @__kmpc_target_init(%struct.ident_t*, i8, i1, i1)
348
349; Function Attrs: convergent
350declare i32 @no_openmp(i32*) #1
351
352; Function Attrs: convergent nounwind readonly willreturn
353declare void @pure() #2
354
355declare i8* @__kmpc_alloc_shared(i64)
356declare void @__kmpc_free_shared(i8* nocapture, i64)
357declare void @usei8ptr(i8*) #1
358
359; Function Attrs: nounwind
360declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #3
361
362declare void @__kmpc_target_deinit(%struct.ident_t*, i8, i1)
363
364; Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn
365declare void @llvm.experimental.noalias.scope.decl(metadata) #4
366
367attributes #0 = { convergent norecurse nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
368attributes #1 = { convergent "frame-pointer"="all" "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
369attributes #2 = { convergent nounwind readonly willreturn "frame-pointer"="all" "llvm.assume"="ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
370attributes #3 = { nounwind }
371attributes #4 = { inaccessiblememonly nofree nosync nounwind willreturn }
372attributes #5 = { convergent nounwind "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" }
373
374!omp_offload.info = !{!0}
375!nvvm.annotations = !{!1}
376!llvm.module.flags = !{!2, !3, !4, !5, !6}
377!llvm.ident = !{!7}
378
379!0 = !{i32 0, i32 42, i32 16513658, !"sequential_loop", i32 6, i32 0}
380!1 = !{void (i32*, i64)* @__omp_offloading_2a_fbfa7a_sequential_loop_l6, !"kernel", i32 1}
381!2 = !{i32 1, !"wchar_size", i32 4}
382!3 = !{i32 7, !"openmp", i32 50}
383!4 = !{i32 7, !"openmp-device", i32 50}
384!5 = !{i32 7, !"PIC Level", i32 2}
385!6 = !{i32 7, !"frame-pointer", i32 2}
386!7 = !{!"clang version 14.0.0"}
387!8 = !{!9}
388!9 = distinct !{!9, !10, !"__omp_outlined__: %__context"}
389!10 = distinct !{!10, !"__omp_outlined__"}
390!11 = distinct !{!11, !12}
391!12 = !{!"llvm.loop.mustprogress"}
392;.
393; CHECK: attributes #[[ATTR0]] = { convergent norecurse nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
394; CHECK: attributes #[[ATTR1:[0-9]+]] = { alwaysinline }
395; CHECK: attributes #[[ATTR2:[0-9]+]] = { convergent "frame-pointer"="all" "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
396; CHECK: attributes #[[ATTR3:[0-9]+]] = { convergent nounwind readonly willreturn "frame-pointer"="all" "llvm.assume"="ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
397; CHECK: attributes #[[ATTR4:[0-9]+]] = { nosync nounwind allocsize(0) }
398; CHECK: attributes #[[ATTR5:[0-9]+]] = { nosync nounwind }
399; CHECK: attributes #[[ATTR6]] = { nounwind }
400; CHECK: attributes #[[ATTR7:[0-9]+]] = { inaccessiblememonly nocallback nofree nosync nounwind willreturn }
401; CHECK: attributes #[[ATTR8:[0-9]+]] = { convergent nounwind }
402; CHECK: attributes #[[ATTR9]] = { nounwind willreturn }
403; CHECK: attributes #[[ATTR10]] = { convergent nounwind "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" }
404;.
405; CHECK-DISABLED: attributes #[[ATTR0]] = { convergent norecurse nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
406; CHECK-DISABLED: attributes #[[ATTR1:[0-9]+]] = { alwaysinline }
407; CHECK-DISABLED: attributes #[[ATTR2:[0-9]+]] = { convergent "frame-pointer"="all" "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
408; CHECK-DISABLED: attributes #[[ATTR3:[0-9]+]] = { convergent nounwind readonly willreturn "frame-pointer"="all" "llvm.assume"="ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" }
409; CHECK-DISABLED: attributes #[[ATTR4:[0-9]+]] = { nosync nounwind allocsize(0) }
410; CHECK-DISABLED: attributes #[[ATTR5:[0-9]+]] = { nosync nounwind }
411; CHECK-DISABLED: attributes #[[ATTR6]] = { nounwind }
412; CHECK-DISABLED: attributes #[[ATTR7:[0-9]+]] = { inaccessiblememonly nocallback nofree nosync nounwind willreturn }
413; CHECK-DISABLED: attributes #[[ATTR8:[0-9]+]] = { convergent nounwind }
414; CHECK-DISABLED: attributes #[[ATTR9]] = { nounwind willreturn }
415; CHECK-DISABLED: attributes #[[ATTR10]] = { convergent nounwind "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" }
416;.
417; CHECK: [[META0:![0-9]+]] = !{i32 0, i32 42, i32 16513658, !"sequential_loop", i32 6, i32 0}
418; CHECK: [[META1:![0-9]+]] = !{void (i32*, i64)* @__omp_offloading_2a_fbfa7a_sequential_loop_l6, !"kernel", i32 1}
419; CHECK: [[META2:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
420; CHECK: [[META3:![0-9]+]] = !{i32 7, !"openmp", i32 50}
421; CHECK: [[META4:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
422; CHECK: [[META5:![0-9]+]] = !{i32 7, !"PIC Level", i32 2}
423; CHECK: [[META6:![0-9]+]] = !{i32 7, !"frame-pointer", i32 2}
424; CHECK: [[META7:![0-9]+]] = !{!"clang version 14.0.0"}
425; CHECK: [[META8:![0-9]+]] = !{!9}
426; CHECK: [[META9:![0-9]+]] = distinct !{!9, !10, !"__omp_outlined__: %__context"}
427; CHECK: [[META10:![0-9]+]] = distinct !{!10, !"__omp_outlined__"}
428; CHECK: [[LOOP11]] = distinct !{!11, !12}
429; CHECK: [[META12:![0-9]+]] = !{!"llvm.loop.mustprogress"}
430;.
431; CHECK-DISABLED: [[META0:![0-9]+]] = !{i32 0, i32 42, i32 16513658, !"sequential_loop", i32 6, i32 0}
432; CHECK-DISABLED: [[META1:![0-9]+]] = !{void (i32*, i64)* @__omp_offloading_2a_fbfa7a_sequential_loop_l6, !"kernel", i32 1}
433; CHECK-DISABLED: [[META2:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
434; CHECK-DISABLED: [[META3:![0-9]+]] = !{i32 7, !"openmp", i32 50}
435; CHECK-DISABLED: [[META4:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
436; CHECK-DISABLED: [[META5:![0-9]+]] = !{i32 7, !"PIC Level", i32 2}
437; CHECK-DISABLED: [[META6:![0-9]+]] = !{i32 7, !"frame-pointer", i32 2}
438; CHECK-DISABLED: [[META7:![0-9]+]] = !{!"clang version 14.0.0"}
439; CHECK-DISABLED: [[META8:![0-9]+]] = !{!9}
440; CHECK-DISABLED: [[META9:![0-9]+]] = distinct !{!9, !10, !"__omp_outlined__: %__context"}
441; CHECK-DISABLED: [[META10:![0-9]+]] = distinct !{!10, !"__omp_outlined__"}
442; CHECK-DISABLED: [[LOOP11]] = distinct !{!11, !12}
443; CHECK-DISABLED: [[META12:![0-9]+]] = !{!"llvm.loop.mustprogress"}
444;.
445