1a2223612SMichael Kruse // Check code generation
2532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
3a2223612SMichael Kruse 
4a2223612SMichael Kruse // Check same results after serialization round-trip
5532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-pch -o %t %s
6532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -include-pch %t -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
7a2223612SMichael Kruse // expected-no-diagnostics
8a2223612SMichael Kruse 
9a2223612SMichael Kruse #ifndef HEADER
10a2223612SMichael Kruse #define HEADER
11a2223612SMichael Kruse 
12a2223612SMichael Kruse // placeholder for loop body code.
body(...)13a2223612SMichael Kruse extern "C" void body(...) {}
14a2223612SMichael Kruse 
15a2223612SMichael Kruse 
16a2223612SMichael Kruse // IR-LABEL: @func(
17a2223612SMichael Kruse // IR-NEXT:  [[ENTRY:.*]]:
18a2223612SMichael Kruse // IR-NEXT:    %[[START_ADDR:.+]] = alloca i32, align 4
19a2223612SMichael Kruse // IR-NEXT:    %[[END_ADDR:.+]] = alloca i32, align 4
20a2223612SMichael Kruse // IR-NEXT:    %[[STEP_ADDR:.+]] = alloca i32, align 4
21a2223612SMichael Kruse // IR-NEXT:    %[[DOTOMP_IV:.+]] = alloca i64, align 8
22a2223612SMichael Kruse // IR-NEXT:    %[[TMP:.+]] = alloca i32, align 4
23a2223612SMichael Kruse // IR-NEXT:    %[[TMP1:.+]] = alloca i32, align 4
24a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_:.+]] = alloca i32, align 4
25a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_2:.+]] = alloca i32, align 4
26a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_3:.+]] = alloca i32, align 4
27a2223612SMichael Kruse // IR-NEXT:    %[[J:.+]] = alloca i32, align 4
28a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_4:.+]] = alloca i32, align 4
29a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_5:.+]] = alloca i32, align 4
30a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_6:.+]] = alloca i32, align 4
31a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_7:.+]] = alloca i32, align 4
32a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_10:.+]] = alloca i32, align 4
33a2223612SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_12:.+]] = alloca i64, align 8
34a2223612SMichael Kruse // IR-NEXT:    %[[I:.+]] = alloca i32, align 4
35a2223612SMichael Kruse // IR-NEXT:    %[[DOTUNROLLED_IV_J:.+]] = alloca i32, align 4
36a2223612SMichael Kruse // IR-NEXT:    %[[DOTOMP_LB:.+]] = alloca i64, align 8
37a2223612SMichael Kruse // IR-NEXT:    %[[DOTOMP_UB:.+]] = alloca i64, align 8
38a2223612SMichael Kruse // IR-NEXT:    %[[DOTOMP_STRIDE:.+]] = alloca i64, align 8
39a2223612SMichael Kruse // IR-NEXT:    %[[DOTOMP_IS_LAST:.+]] = alloca i32, align 4
40a2223612SMichael Kruse // IR-NEXT:    %[[I22:.+]] = alloca i32, align 4
41a2223612SMichael Kruse // IR-NEXT:    %[[DOTUNROLLED_IV_J23:.+]] = alloca i32, align 4
42a2223612SMichael Kruse // IR-NEXT:    %[[DOTUNROLL_INNER_IV_J:.+]] = alloca i32, align 4
43a2223612SMichael Kruse // IR-NEXT:    %[[TMP0:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @2)
44a2223612SMichael Kruse // IR-NEXT:    store i32 %[[START:.+]], i32* %[[START_ADDR]], align 4
45a2223612SMichael Kruse // IR-NEXT:    store i32 %[[END:.+]], i32* %[[END_ADDR]], align 4
46a2223612SMichael Kruse // IR-NEXT:    store i32 %[[STEP:.+]], i32* %[[STEP_ADDR]], align 4
47a2223612SMichael Kruse // IR-NEXT:    %[[TMP1_1:.+]] = load i32, i32* %[[START_ADDR]], align 4
48a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP1_1]], i32* %[[DOTCAPTURE_EXPR_]], align 4
49a2223612SMichael Kruse // IR-NEXT:    %[[TMP2:.+]] = load i32, i32* %[[END_ADDR]], align 4
50a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP2]], i32* %[[DOTCAPTURE_EXPR_2]], align 4
51a2223612SMichael Kruse // IR-NEXT:    %[[TMP3:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
52a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP3]], i32* %[[DOTCAPTURE_EXPR_3]], align 4
53a2223612SMichael Kruse // IR-NEXT:    %[[TMP4:.+]] = load i32, i32* %[[START_ADDR]], align 4
54a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP4]], i32* %[[J]], align 4
55a2223612SMichael Kruse // IR-NEXT:    %[[TMP5:.+]] = load i32, i32* %[[START_ADDR]], align 4
56a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP5]], i32* %[[DOTCAPTURE_EXPR_4]], align 4
57a2223612SMichael Kruse // IR-NEXT:    %[[TMP6:.+]] = load i32, i32* %[[END_ADDR]], align 4
58a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP6]], i32* %[[DOTCAPTURE_EXPR_5]], align 4
59a2223612SMichael Kruse // IR-NEXT:    %[[TMP7:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
60a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP7]], i32* %[[DOTCAPTURE_EXPR_6]], align 4
61a2223612SMichael Kruse // IR-NEXT:    %[[TMP8:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_5]], align 4
62a2223612SMichael Kruse // IR-NEXT:    %[[TMP9:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_4]], align 4
63a2223612SMichael Kruse // IR-NEXT:    %[[SUB:.+]] = sub i32 %[[TMP8]], %[[TMP9]]
64a2223612SMichael Kruse // IR-NEXT:    %[[SUB8:.+]] = sub i32 %[[SUB]], 1
65a2223612SMichael Kruse // IR-NEXT:    %[[TMP10:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_6]], align 4
66a2223612SMichael Kruse // IR-NEXT:    %[[ADD:.+]] = add i32 %[[SUB8]], %[[TMP10]]
67a2223612SMichael Kruse // IR-NEXT:    %[[TMP11:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_6]], align 4
68a2223612SMichael Kruse // IR-NEXT:    %[[DIV:.+]] = udiv i32 %[[ADD]], %[[TMP11]]
69a2223612SMichael Kruse // IR-NEXT:    %[[SUB9:.+]] = sub i32 %[[DIV]], 1
70a2223612SMichael Kruse // IR-NEXT:    store i32 %[[SUB9]], i32* %[[DOTCAPTURE_EXPR_7]], align 4
71a2223612SMichael Kruse // IR-NEXT:    %[[TMP12:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_7]], align 4
72a2223612SMichael Kruse // IR-NEXT:    %[[ADD11:.+]] = add i32 %[[TMP12]], 1
73a2223612SMichael Kruse // IR-NEXT:    store i32 %[[ADD11]], i32* %[[DOTCAPTURE_EXPR_10]], align 4
74a2223612SMichael Kruse // IR-NEXT:    %[[TMP13:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
75a2223612SMichael Kruse // IR-NEXT:    %[[TMP14:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
76a2223612SMichael Kruse // IR-NEXT:    %[[SUB13:.+]] = sub i32 %[[TMP13]], %[[TMP14]]
77a2223612SMichael Kruse // IR-NEXT:    %[[SUB14:.+]] = sub i32 %[[SUB13]], 1
78a2223612SMichael Kruse // IR-NEXT:    %[[TMP15:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
79a2223612SMichael Kruse // IR-NEXT:    %[[ADD15:.+]] = add i32 %[[SUB14]], %[[TMP15]]
80a2223612SMichael Kruse // IR-NEXT:    %[[TMP16:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
81a2223612SMichael Kruse // IR-NEXT:    %[[DIV16:.+]] = udiv i32 %[[ADD15]], %[[TMP16]]
82a2223612SMichael Kruse // IR-NEXT:    %[[CONV:.+]] = zext i32 %[[DIV16]] to i64
83a2223612SMichael Kruse // IR-NEXT:    %[[TMP17:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_10]], align 4
84a2223612SMichael Kruse // IR-NEXT:    %[[SUB17:.+]] = sub i32 %[[TMP17]], -1
85a2223612SMichael Kruse // IR-NEXT:    %[[DIV18:.+]] = udiv i32 %[[SUB17]], 2
86a2223612SMichael Kruse // IR-NEXT:    %[[CONV19:.+]] = zext i32 %[[DIV18]] to i64
87a2223612SMichael Kruse // IR-NEXT:    %[[MUL:.+]] = mul nsw i64 %[[CONV]], %[[CONV19]]
88a2223612SMichael Kruse // IR-NEXT:    %[[SUB20:.+]] = sub nsw i64 %[[MUL]], 1
89a2223612SMichael Kruse // IR-NEXT:    store i64 %[[SUB20]], i64* %[[DOTCAPTURE_EXPR_12]], align 8
90a2223612SMichael Kruse // IR-NEXT:    %[[TMP18:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
91a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP18]], i32* %[[I]], align 4
92a2223612SMichael Kruse // IR-NEXT:    store i32 0, i32* %[[DOTUNROLLED_IV_J]], align 4
93a2223612SMichael Kruse // IR-NEXT:    %[[TMP19:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
94a2223612SMichael Kruse // IR-NEXT:    %[[TMP20:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
95a2223612SMichael Kruse // IR-NEXT:    %[[CMP:.+]] = icmp slt i32 %[[TMP19]], %[[TMP20]]
96a2223612SMichael Kruse // IR-NEXT:    br i1 %[[CMP]], label %[[LAND_LHS_TRUE:.+]], label %[[OMP_PRECOND_END:.+]]
97a2223612SMichael Kruse // IR-EMPTY:
98a2223612SMichael Kruse // IR-NEXT:  [[LAND_LHS_TRUE]]:
99a2223612SMichael Kruse // IR-NEXT:    %[[TMP21:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_10]], align 4
100a2223612SMichael Kruse // IR-NEXT:    %[[CMP21:.+]] = icmp ult i32 0, %[[TMP21]]
101a2223612SMichael Kruse // IR-NEXT:    br i1 %[[CMP21]], label %[[OMP_PRECOND_THEN:.+]], label %[[OMP_PRECOND_END]]
102a2223612SMichael Kruse // IR-EMPTY:
103a2223612SMichael Kruse // IR-NEXT:  [[OMP_PRECOND_THEN]]:
104a2223612SMichael Kruse // IR-NEXT:    store i64 0, i64* %[[DOTOMP_LB]], align 8
105a2223612SMichael Kruse // IR-NEXT:    %[[TMP22:.+]] = load i64, i64* %[[DOTCAPTURE_EXPR_12]], align 8
106a2223612SMichael Kruse // IR-NEXT:    store i64 %[[TMP22]], i64* %[[DOTOMP_UB]], align 8
107a2223612SMichael Kruse // IR-NEXT:    store i64 1, i64* %[[DOTOMP_STRIDE]], align 8
108a2223612SMichael Kruse // IR-NEXT:    store i32 0, i32* %[[DOTOMP_IS_LAST]], align 4
109a2223612SMichael Kruse // IR-NEXT:    call void @__kmpc_for_static_init_8(%struct.ident_t* @1, i32 %[[TMP0]], i32 34, i32* %[[DOTOMP_IS_LAST]], i64* %[[DOTOMP_LB]], i64* %[[DOTOMP_UB]], i64* %[[DOTOMP_STRIDE]], i64 1, i64 1)
110a2223612SMichael Kruse // IR-NEXT:    %[[TMP23:.+]] = load i64, i64* %[[DOTOMP_UB]], align 8
111a2223612SMichael Kruse // IR-NEXT:    %[[TMP24:.+]] = load i64, i64* %[[DOTCAPTURE_EXPR_12]], align 8
112a2223612SMichael Kruse // IR-NEXT:    %[[CMP24:.+]] = icmp sgt i64 %[[TMP23]], %[[TMP24]]
113a2223612SMichael Kruse // IR-NEXT:    br i1 %[[CMP24]], label %[[COND_TRUE:.+]], label %[[COND_FALSE:.+]]
114a2223612SMichael Kruse // IR-EMPTY:
115a2223612SMichael Kruse // IR-NEXT:  [[COND_TRUE]]:
116a2223612SMichael Kruse // IR-NEXT:    %[[TMP25:.+]] = load i64, i64* %[[DOTCAPTURE_EXPR_12]], align 8
117a2223612SMichael Kruse // IR-NEXT:    br label %[[COND_END:.+]]
118a2223612SMichael Kruse // IR-EMPTY:
119a2223612SMichael Kruse // IR-NEXT:  [[COND_FALSE]]:
120a2223612SMichael Kruse // IR-NEXT:    %[[TMP26:.+]] = load i64, i64* %[[DOTOMP_UB]], align 8
121a2223612SMichael Kruse // IR-NEXT:    br label %[[COND_END]]
122a2223612SMichael Kruse // IR-EMPTY:
123a2223612SMichael Kruse // IR-NEXT:  [[COND_END]]:
124a2223612SMichael Kruse // IR-NEXT:    %[[COND:.+]] = phi i64 [ %[[TMP25]], %[[COND_TRUE]] ], [ %[[TMP26]], %[[COND_FALSE]] ]
125a2223612SMichael Kruse // IR-NEXT:    store i64 %[[COND]], i64* %[[DOTOMP_UB]], align 8
126a2223612SMichael Kruse // IR-NEXT:    %[[TMP27:.+]] = load i64, i64* %[[DOTOMP_LB]], align 8
127a2223612SMichael Kruse // IR-NEXT:    store i64 %[[TMP27]], i64* %[[DOTOMP_IV]], align 8
128a2223612SMichael Kruse // IR-NEXT:    br label %[[OMP_INNER_FOR_COND:.+]]
129a2223612SMichael Kruse // IR-EMPTY:
130a2223612SMichael Kruse // IR-NEXT:  [[OMP_INNER_FOR_COND]]:
131a2223612SMichael Kruse // IR-NEXT:    %[[TMP28:.+]] = load i64, i64* %[[DOTOMP_IV]], align 8
132a2223612SMichael Kruse // IR-NEXT:    %[[TMP29:.+]] = load i64, i64* %[[DOTOMP_UB]], align 8
133a2223612SMichael Kruse // IR-NEXT:    %[[CMP25:.+]] = icmp sle i64 %[[TMP28]], %[[TMP29]]
134a2223612SMichael Kruse // IR-NEXT:    br i1 %[[CMP25]], label %[[OMP_INNER_FOR_BODY:.+]], label %[[OMP_INNER_FOR_END:.+]]
135a2223612SMichael Kruse // IR-EMPTY:
136a2223612SMichael Kruse // IR-NEXT:  [[OMP_INNER_FOR_BODY]]:
137a2223612SMichael Kruse // IR-NEXT:    %[[TMP30:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
138a2223612SMichael Kruse // IR-NEXT:    %[[CONV26:.+]] = sext i32 %[[TMP30]] to i64
139a2223612SMichael Kruse // IR-NEXT:    %[[TMP31:.+]] = load i64, i64* %[[DOTOMP_IV]], align 8
140a2223612SMichael Kruse // IR-NEXT:    %[[TMP32:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_10]], align 4
141a2223612SMichael Kruse // IR-NEXT:    %[[SUB27:.+]] = sub i32 %[[TMP32]], -1
142a2223612SMichael Kruse // IR-NEXT:    %[[DIV28:.+]] = udiv i32 %[[SUB27]], 2
143a2223612SMichael Kruse // IR-NEXT:    %[[MUL29:.+]] = mul i32 1, %[[DIV28]]
144a2223612SMichael Kruse // IR-NEXT:    %[[CONV30:.+]] = zext i32 %[[MUL29]] to i64
145a2223612SMichael Kruse // IR-NEXT:    %[[DIV31:.+]] = sdiv i64 %[[TMP31]], %[[CONV30]]
146a2223612SMichael Kruse // IR-NEXT:    %[[TMP33:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
147a2223612SMichael Kruse // IR-NEXT:    %[[CONV32:.+]] = sext i32 %[[TMP33]] to i64
148a2223612SMichael Kruse // IR-NEXT:    %[[MUL33:.+]] = mul nsw i64 %[[DIV31]], %[[CONV32]]
149a2223612SMichael Kruse // IR-NEXT:    %[[ADD34:.+]] = add nsw i64 %[[CONV26]], %[[MUL33]]
150a2223612SMichael Kruse // IR-NEXT:    %[[CONV35:.+]] = trunc i64 %[[ADD34]] to i32
151a2223612SMichael Kruse // IR-NEXT:    store i32 %[[CONV35]], i32* %[[I22]], align 4
152a2223612SMichael Kruse // IR-NEXT:    %[[TMP34:.+]] = load i64, i64* %[[DOTOMP_IV]], align 8
153a2223612SMichael Kruse // IR-NEXT:    %[[TMP35:.+]] = load i64, i64* %[[DOTOMP_IV]], align 8
154a2223612SMichael Kruse // IR-NEXT:    %[[TMP36:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_10]], align 4
155a2223612SMichael Kruse // IR-NEXT:    %[[SUB36:.+]] = sub i32 %[[TMP36]], -1
156a2223612SMichael Kruse // IR-NEXT:    %[[DIV37:.+]] = udiv i32 %[[SUB36]], 2
157a2223612SMichael Kruse // IR-NEXT:    %[[MUL38:.+]] = mul i32 1, %[[DIV37]]
158a2223612SMichael Kruse // IR-NEXT:    %[[CONV39:.+]] = zext i32 %[[MUL38]] to i64
159a2223612SMichael Kruse // IR-NEXT:    %[[DIV40:.+]] = sdiv i64 %[[TMP35]], %[[CONV39]]
160a2223612SMichael Kruse // IR-NEXT:    %[[TMP37:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_10]], align 4
161a2223612SMichael Kruse // IR-NEXT:    %[[SUB41:.+]] = sub i32 %[[TMP37]], -1
162a2223612SMichael Kruse // IR-NEXT:    %[[DIV42:.+]] = udiv i32 %[[SUB41]], 2
163a2223612SMichael Kruse // IR-NEXT:    %[[MUL43:.+]] = mul i32 1, %[[DIV42]]
164a2223612SMichael Kruse // IR-NEXT:    %[[CONV44:.+]] = zext i32 %[[MUL43]] to i64
165a2223612SMichael Kruse // IR-NEXT:    %[[MUL45:.+]] = mul nsw i64 %[[DIV40]], %[[CONV44]]
166a2223612SMichael Kruse // IR-NEXT:    %[[SUB46:.+]] = sub nsw i64 %[[TMP34]], %[[MUL45]]
167a2223612SMichael Kruse // IR-NEXT:    %[[MUL47:.+]] = mul nsw i64 %[[SUB46]], 2
168a2223612SMichael Kruse // IR-NEXT:    %[[ADD48:.+]] = add nsw i64 0, %[[MUL47]]
169a2223612SMichael Kruse // IR-NEXT:    %[[CONV49:.+]] = trunc i64 %[[ADD48]] to i32
170a2223612SMichael Kruse // IR-NEXT:    store i32 %[[CONV49]], i32* %[[DOTUNROLLED_IV_J23]], align 4
171a2223612SMichael Kruse // IR-NEXT:    %[[TMP38:.+]] = load i32, i32* %[[DOTUNROLLED_IV_J23]], align 4
172a2223612SMichael Kruse // IR-NEXT:    store i32 %[[TMP38]], i32* %[[DOTUNROLL_INNER_IV_J]], align 4
173a2223612SMichael Kruse // IR-NEXT:    br label %[[FOR_COND:.+]]
174a2223612SMichael Kruse // IR-EMPTY:
175a2223612SMichael Kruse // IR-NEXT:  [[FOR_COND]]:
176a2223612SMichael Kruse // IR-NEXT:    %[[TMP39:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], align 4
177a2223612SMichael Kruse // IR-NEXT:    %[[TMP40:.+]] = load i32, i32* %[[DOTUNROLLED_IV_J23]], align 4
178a2223612SMichael Kruse // IR-NEXT:    %[[ADD50:.+]] = add i32 %[[TMP40]], 2
179*acec0700SMichael Kruse // IR-NEXT:    %[[CMP51:.+]] = icmp ult i32 %[[TMP39]], %[[ADD50]]
180a2223612SMichael Kruse // IR-NEXT:    br i1 %[[CMP51]], label %[[LAND_RHS:.+]], label %[[LAND_END:.+]]
181a2223612SMichael Kruse // IR-EMPTY:
182a2223612SMichael Kruse // IR-NEXT:  [[LAND_RHS]]:
183a2223612SMichael Kruse // IR-NEXT:    %[[TMP41:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], align 4
184a2223612SMichael Kruse // IR-NEXT:    %[[TMP42:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_7]], align 4
185a2223612SMichael Kruse // IR-NEXT:    %[[ADD52:.+]] = add i32 %[[TMP42]], 1
186*acec0700SMichael Kruse // IR-NEXT:    %[[CMP53:.+]] = icmp ult i32 %[[TMP41]], %[[ADD52]]
187a2223612SMichael Kruse // IR-NEXT:    br label %[[LAND_END]]
188a2223612SMichael Kruse // IR-EMPTY:
189a2223612SMichael Kruse // IR-NEXT:  [[LAND_END]]:
190a2223612SMichael Kruse // IR-NEXT:    %[[TMP43:.+]] = phi i1 [ false, %[[FOR_COND]] ], [ %[[CMP53]], %[[LAND_RHS]] ]
191a2223612SMichael Kruse // IR-NEXT:    br i1 %[[TMP43]], label %[[FOR_BODY:.+]], label %[[FOR_END:.+]]
192a2223612SMichael Kruse // IR-EMPTY:
193a2223612SMichael Kruse // IR-NEXT:  [[FOR_BODY]]:
194a2223612SMichael Kruse // IR-NEXT:    %[[TMP44:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_4]], align 4
195a2223612SMichael Kruse // IR-NEXT:    %[[TMP45:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], align 4
196a2223612SMichael Kruse // IR-NEXT:    %[[TMP46:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_6]], align 4
197a2223612SMichael Kruse // IR-NEXT:    %[[MUL54:.+]] = mul i32 %[[TMP45]], %[[TMP46]]
198a2223612SMichael Kruse // IR-NEXT:    %[[ADD55:.+]] = add i32 %[[TMP44]], %[[MUL54]]
199a2223612SMichael Kruse // IR-NEXT:    store i32 %[[ADD55]], i32* %[[J]], align 4
200a2223612SMichael Kruse // IR-NEXT:    %[[TMP47:.+]] = load i32, i32* %[[START_ADDR]], align 4
201a2223612SMichael Kruse // IR-NEXT:    %[[TMP48:.+]] = load i32, i32* %[[END_ADDR]], align 4
202a2223612SMichael Kruse // IR-NEXT:    %[[TMP49:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
203a2223612SMichael Kruse // IR-NEXT:    %[[TMP50:.+]] = load i32, i32* %[[I22]], align 4
204a2223612SMichael Kruse // IR-NEXT:    %[[TMP51:.+]] = load i32, i32* %[[J]], align 4
2051b1c8d83Shyeongyu kim // IR-NEXT:    call void (...) @body(i32 noundef %[[TMP47]], i32 noundef %[[TMP48]], i32 noundef %[[TMP49]], i32 noundef %[[TMP50]], i32 noundef %[[TMP51]])
206a2223612SMichael Kruse // IR-NEXT:    br label %[[FOR_INC:.+]]
207a2223612SMichael Kruse // IR-EMPTY:
208a2223612SMichael Kruse // IR-NEXT:  [[FOR_INC]]:
209a2223612SMichael Kruse // IR-NEXT:    %[[TMP52:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], align 4
210a2223612SMichael Kruse // IR-NEXT:    %[[INC:.+]] = add i32 %[[TMP52]], 1
211a2223612SMichael Kruse // IR-NEXT:    store i32 %[[INC]], i32* %[[DOTUNROLL_INNER_IV_J]], align 4
212a2223612SMichael Kruse // IR-NEXT:    br label %[[FOR_COND]], !llvm.loop ![[LOOP2:[0-9]+]]
213a2223612SMichael Kruse // IR-EMPTY:
214a2223612SMichael Kruse // IR-NEXT:  [[FOR_END]]:
215a2223612SMichael Kruse // IR-NEXT:    br label %[[OMP_BODY_CONTINUE:.+]]
216a2223612SMichael Kruse // IR-EMPTY:
217a2223612SMichael Kruse // IR-NEXT:  [[OMP_BODY_CONTINUE]]:
218a2223612SMichael Kruse // IR-NEXT:    br label %[[OMP_INNER_FOR_INC:.+]]
219a2223612SMichael Kruse // IR-EMPTY:
220a2223612SMichael Kruse // IR-NEXT:  [[OMP_INNER_FOR_INC]]:
221a2223612SMichael Kruse // IR-NEXT:    %[[TMP53:.+]] = load i64, i64* %[[DOTOMP_IV]], align 8
222a2223612SMichael Kruse // IR-NEXT:    %[[ADD56:.+]] = add nsw i64 %[[TMP53]], 1
223a2223612SMichael Kruse // IR-NEXT:    store i64 %[[ADD56]], i64* %[[DOTOMP_IV]], align 8
224a2223612SMichael Kruse // IR-NEXT:    br label %[[OMP_INNER_FOR_COND]]
225a2223612SMichael Kruse // IR-EMPTY:
226a2223612SMichael Kruse // IR-NEXT:  [[OMP_INNER_FOR_END]]:
227a2223612SMichael Kruse // IR-NEXT:    br label %[[OMP_LOOP_EXIT:.+]]
228a2223612SMichael Kruse // IR-EMPTY:
229a2223612SMichael Kruse // IR-NEXT:  [[OMP_LOOP_EXIT]]:
230a2223612SMichael Kruse // IR-NEXT:    call void @__kmpc_for_static_fini(%struct.ident_t* @1, i32 %[[TMP0]])
231a2223612SMichael Kruse // IR-NEXT:    br label %[[OMP_PRECOND_END]]
232a2223612SMichael Kruse // IR-EMPTY:
233a2223612SMichael Kruse // IR-NEXT:  [[OMP_PRECOND_END]]:
234a2223612SMichael Kruse // IR-NEXT:    call void @__kmpc_barrier(%struct.ident_t* @3, i32 %[[TMP0]])
235a2223612SMichael Kruse // IR-NEXT:    ret void
236a2223612SMichael Kruse // IR-NEXT:  }
func(int start,int end,int step)237a2223612SMichael Kruse extern "C" void func(int start, int end, int step) {
238a2223612SMichael Kruse   #pragma omp for collapse(2)
239a2223612SMichael Kruse   for (int i = start; i < end; i+=step) {
240a2223612SMichael Kruse     #pragma omp unroll partial
241a2223612SMichael Kruse     for (int j = start; j < end; j+=step)
242a2223612SMichael Kruse         body(start, end, step, i, j);
243a2223612SMichael Kruse   }
244a2223612SMichael Kruse }
245a2223612SMichael Kruse 
246a2223612SMichael Kruse #endif /* HEADER */
247a2223612SMichael Kruse 
248a2223612SMichael Kruse 
249a2223612SMichael Kruse // IR: ![[LOOP2]] = distinct !{![[LOOP2]], ![[LOOPPROP3:[0-9]+]], ![[LOOPPROP4:[0-9]+]]}
250a2223612SMichael Kruse // IR: ![[LOOPPROP3]] = !{!"llvm.loop.mustprogress"}
251a2223612SMichael Kruse // IR: ![[LOOPPROP4]] = !{!"llvm.loop.unroll.count", i32 2}
252