107a6beb4SMichael Kruse // Check code generation
207a6beb4SMichael Kruse // RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
307a6beb4SMichael Kruse 
407a6beb4SMichael Kruse // Check same results after serialization round-trip
507a6beb4SMichael Kruse // RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-pch -o %t %s
607a6beb4SMichael Kruse // RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -include-pch %t -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
707a6beb4SMichael Kruse // expected-no-diagnostics
807a6beb4SMichael Kruse 
907a6beb4SMichael Kruse // Account for multiple transformations of a loop before consumed by
1007a6beb4SMichael Kruse // #pragma omp for.
1107a6beb4SMichael Kruse 
1207a6beb4SMichael Kruse #ifndef HEADER
1307a6beb4SMichael Kruse #define HEADER
1407a6beb4SMichael Kruse 
1507a6beb4SMichael Kruse // placeholder for loop body code.
1607a6beb4SMichael Kruse extern "C" void body(...) {}
1707a6beb4SMichael Kruse 
1807a6beb4SMichael Kruse 
1907a6beb4SMichael Kruse // IR-LABEL: @func(
2007a6beb4SMichael Kruse // IR-NEXT:  [[ENTRY:.*]]:
2107a6beb4SMichael Kruse // IR-NEXT:    %[[START_ADDR:.+]] = alloca i32, align 4
2207a6beb4SMichael Kruse // IR-NEXT:    %[[END_ADDR:.+]] = alloca i32, align 4
2307a6beb4SMichael Kruse // IR-NEXT:    %[[STEP_ADDR:.+]] = alloca i32, align 4
2407a6beb4SMichael Kruse // IR-NEXT:    %[[DOTOMP_IV:.+]] = alloca i32, align 4
2507a6beb4SMichael Kruse // IR-NEXT:    %[[TMP:.+]] = alloca i32, align 4
2607a6beb4SMichael Kruse // IR-NEXT:    %[[I:.+]] = alloca i32, align 4
2707a6beb4SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_:.+]] = alloca i32, align 4
2807a6beb4SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_1:.+]] = alloca i32, align 4
2907a6beb4SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_2:.+]] = alloca i32, align 4
3007a6beb4SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_3:.+]] = alloca i32, align 4
3107a6beb4SMichael Kruse // IR-NEXT:    %[[DOTFLOOR_0_IV_I:.+]] = alloca i32, align 4
3207a6beb4SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_6:.+]] = alloca i32, align 4
3307a6beb4SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_8:.+]] = alloca i32, align 4
3407a6beb4SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_12:.+]] = alloca i32, align 4
3507a6beb4SMichael Kruse // IR-NEXT:    %[[DOTCAPTURE_EXPR_14:.+]] = alloca i32, align 4
3607a6beb4SMichael Kruse // IR-NEXT:    %[[DOTFLOOR_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
3707a6beb4SMichael Kruse // IR-NEXT:    %[[DOTOMP_LB:.+]] = alloca i32, align 4
3807a6beb4SMichael Kruse // IR-NEXT:    %[[DOTOMP_UB:.+]] = alloca i32, align 4
3907a6beb4SMichael Kruse // IR-NEXT:    %[[DOTOMP_STRIDE:.+]] = alloca i32, align 4
4007a6beb4SMichael Kruse // IR-NEXT:    %[[DOTOMP_IS_LAST:.+]] = alloca i32, align 4
4107a6beb4SMichael Kruse // IR-NEXT:    %[[DOTFLOOR_0_IV__FLOOR_0_IV_I18:.+]] = alloca i32, align 4
4207a6beb4SMichael Kruse // IR-NEXT:    %[[DOTTILE_0_IV__FLOOR_0_IV_I:.+]] = alloca i32, align 4
4307a6beb4SMichael Kruse // IR-NEXT:    %[[DOTTILE_0_IV_I:.+]] = alloca i32, align 4
4407a6beb4SMichael Kruse // IR-NEXT:    %[[TMP0:.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @2)
4507a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[START:.+]], i32* %[[START_ADDR]], align 4
4607a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[END:.+]], i32* %[[END_ADDR]], align 4
4707a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[STEP:.+]], i32* %[[STEP_ADDR]], align 4
4807a6beb4SMichael Kruse // IR-NEXT:    %[[TMP1:.+]] = load i32, i32* %[[START_ADDR]], align 4
4907a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[TMP1]], i32* %[[I]], align 4
5007a6beb4SMichael Kruse // IR-NEXT:    %[[TMP2:.+]] = load i32, i32* %[[START_ADDR]], align 4
5107a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[TMP2]], i32* %[[DOTCAPTURE_EXPR_]], align 4
5207a6beb4SMichael Kruse // IR-NEXT:    %[[TMP3:.+]] = load i32, i32* %[[END_ADDR]], align 4
5307a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[TMP3]], i32* %[[DOTCAPTURE_EXPR_1]], align 4
5407a6beb4SMichael Kruse // IR-NEXT:    %[[TMP4:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
5507a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[TMP4]], i32* %[[DOTCAPTURE_EXPR_2]], align 4
5607a6beb4SMichael Kruse // IR-NEXT:    %[[TMP5:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_1]], align 4
5707a6beb4SMichael Kruse // IR-NEXT:    %[[TMP6:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
5807a6beb4SMichael Kruse // IR-NEXT:    %[[SUB:.+]] = sub i32 %[[TMP5]], %[[TMP6]]
5907a6beb4SMichael Kruse // IR-NEXT:    %[[SUB4:.+]] = sub i32 %[[SUB]], 1
6007a6beb4SMichael Kruse // IR-NEXT:    %[[TMP7:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
6107a6beb4SMichael Kruse // IR-NEXT:    %[[ADD:.+]] = add i32 %[[SUB4]], %[[TMP7]]
6207a6beb4SMichael Kruse // IR-NEXT:    %[[TMP8:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
6307a6beb4SMichael Kruse // IR-NEXT:    %[[DIV:.+]] = udiv i32 %[[ADD]], %[[TMP8]]
6407a6beb4SMichael Kruse // IR-NEXT:    %[[SUB5:.+]] = sub i32 %[[DIV]], 1
6507a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[SUB5]], i32* %[[DOTCAPTURE_EXPR_3]], align 4
6607a6beb4SMichael Kruse // IR-NEXT:    store i32 0, i32* %[[DOTFLOOR_0_IV_I]], align 4
6707a6beb4SMichael Kruse // IR-NEXT:    %[[TMP9:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
6807a6beb4SMichael Kruse // IR-NEXT:    %[[ADD7:.+]] = add i32 %[[TMP9]], 1
6907a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[ADD7]], i32* %[[DOTCAPTURE_EXPR_6]], align 4
7007a6beb4SMichael Kruse // IR-NEXT:    %[[TMP10:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_6]], align 4
7107a6beb4SMichael Kruse // IR-NEXT:    %[[SUB9:.+]] = sub i32 %[[TMP10]], -3
7207a6beb4SMichael Kruse // IR-NEXT:    %[[DIV10:.+]] = udiv i32 %[[SUB9]], 4
7307a6beb4SMichael Kruse // IR-NEXT:    %[[SUB11:.+]] = sub i32 %[[DIV10]], 1
7407a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[SUB11]], i32* %[[DOTCAPTURE_EXPR_8]], align 4
7507a6beb4SMichael Kruse // IR-NEXT:    %[[TMP11:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_8]], align 4
7607a6beb4SMichael Kruse // IR-NEXT:    %[[ADD13:.+]] = add i32 %[[TMP11]], 1
7707a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[ADD13]], i32* %[[DOTCAPTURE_EXPR_12]], align 4
7807a6beb4SMichael Kruse // IR-NEXT:    %[[TMP12:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_12]], align 4
7907a6beb4SMichael Kruse // IR-NEXT:    %[[SUB15:.+]] = sub i32 %[[TMP12]], -2
8007a6beb4SMichael Kruse // IR-NEXT:    %[[DIV16:.+]] = udiv i32 %[[SUB15]], 3
8107a6beb4SMichael Kruse // IR-NEXT:    %[[SUB17:.+]] = sub i32 %[[DIV16]], 1
8207a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[SUB17]], i32* %[[DOTCAPTURE_EXPR_14]], align 4
8307a6beb4SMichael Kruse // IR-NEXT:    store i32 0, i32* %[[DOTFLOOR_0_IV__FLOOR_0_IV_I]], align 4
8407a6beb4SMichael Kruse // IR-NEXT:    %[[TMP13:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_12]], align 4
8507a6beb4SMichael Kruse // IR-NEXT:    %[[CMP:.+]] = icmp ult i32 0, %[[TMP13]]
8607a6beb4SMichael Kruse // IR-NEXT:    br i1 %[[CMP]], label %[[OMP_PRECOND_THEN:.+]], label %[[OMP_PRECOND_END:.+]]
8707a6beb4SMichael Kruse // IR-EMPTY:
8807a6beb4SMichael Kruse // IR-NEXT:  [[OMP_PRECOND_THEN]]:
8907a6beb4SMichael Kruse // IR-NEXT:    store i32 0, i32* %[[DOTOMP_LB]], align 4
9007a6beb4SMichael Kruse // IR-NEXT:    %[[TMP14:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_14]], align 4
9107a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[TMP14]], i32* %[[DOTOMP_UB]], align 4
9207a6beb4SMichael Kruse // IR-NEXT:    store i32 1, i32* %[[DOTOMP_STRIDE]], align 4
9307a6beb4SMichael Kruse // IR-NEXT:    store i32 0, i32* %[[DOTOMP_IS_LAST]], align 4
9407a6beb4SMichael Kruse // IR-NEXT:    call void @__kmpc_for_static_init_4u(%struct.ident_t* @1, i32 %[[TMP0]], i32 34, i32* %[[DOTOMP_IS_LAST]], i32* %[[DOTOMP_LB]], i32* %[[DOTOMP_UB]], i32* %[[DOTOMP_STRIDE]], i32 1, i32 1)
9507a6beb4SMichael Kruse // IR-NEXT:    %[[TMP15:.+]] = load i32, i32* %[[DOTOMP_UB]], align 4
9607a6beb4SMichael Kruse // IR-NEXT:    %[[TMP16:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_14]], align 4
9707a6beb4SMichael Kruse // IR-NEXT:    %[[CMP19:.+]] = icmp ugt i32 %[[TMP15]], %[[TMP16]]
9807a6beb4SMichael Kruse // IR-NEXT:    br i1 %[[CMP19]], label %[[COND_TRUE:.+]], label %[[COND_FALSE:.+]]
9907a6beb4SMichael Kruse // IR-EMPTY:
10007a6beb4SMichael Kruse // IR-NEXT:  [[COND_TRUE]]:
10107a6beb4SMichael Kruse // IR-NEXT:    %[[TMP17:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_14]], align 4
10207a6beb4SMichael Kruse // IR-NEXT:    br label %[[COND_END:.+]]
10307a6beb4SMichael Kruse // IR-EMPTY:
10407a6beb4SMichael Kruse // IR-NEXT:  [[COND_FALSE]]:
10507a6beb4SMichael Kruse // IR-NEXT:    %[[TMP18:.+]] = load i32, i32* %[[DOTOMP_UB]], align 4
10607a6beb4SMichael Kruse // IR-NEXT:    br label %[[COND_END]]
10707a6beb4SMichael Kruse // IR-EMPTY:
10807a6beb4SMichael Kruse // IR-NEXT:  [[COND_END]]:
10907a6beb4SMichael Kruse // IR-NEXT:    %[[COND:.+]] = phi i32 [ %[[TMP17]], %[[COND_TRUE]] ], [ %[[TMP18]], %[[COND_FALSE]] ]
11007a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[COND]], i32* %[[DOTOMP_UB]], align 4
11107a6beb4SMichael Kruse // IR-NEXT:    %[[TMP19:.+]] = load i32, i32* %[[DOTOMP_LB]], align 4
11207a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[TMP19]], i32* %[[DOTOMP_IV]], align 4
11307a6beb4SMichael Kruse // IR-NEXT:    br label %[[OMP_INNER_FOR_COND:.+]]
11407a6beb4SMichael Kruse // IR-EMPTY:
11507a6beb4SMichael Kruse // IR-NEXT:  [[OMP_INNER_FOR_COND]]:
11607a6beb4SMichael Kruse // IR-NEXT:    %[[TMP20:.+]] = load i32, i32* %[[DOTOMP_IV]], align 4
11707a6beb4SMichael Kruse // IR-NEXT:    %[[TMP21:.+]] = load i32, i32* %[[DOTOMP_UB]], align 4
11807a6beb4SMichael Kruse // IR-NEXT:    %[[ADD20:.+]] = add i32 %[[TMP21]], 1
11907a6beb4SMichael Kruse // IR-NEXT:    %[[CMP21:.+]] = icmp ult i32 %[[TMP20]], %[[ADD20]]
12007a6beb4SMichael Kruse // IR-NEXT:    br i1 %[[CMP21]], label %[[OMP_INNER_FOR_BODY:.+]], label %[[OMP_INNER_FOR_END:.+]]
12107a6beb4SMichael Kruse // IR-EMPTY:
12207a6beb4SMichael Kruse // IR-NEXT:  [[OMP_INNER_FOR_BODY]]:
12307a6beb4SMichael Kruse // IR-NEXT:    %[[TMP22:.+]] = load i32, i32* %[[DOTOMP_IV]], align 4
12407a6beb4SMichael Kruse // IR-NEXT:    %[[MUL:.+]] = mul i32 %[[TMP22]], 3
12507a6beb4SMichael Kruse // IR-NEXT:    %[[ADD22:.+]] = add i32 0, %[[MUL]]
12607a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[ADD22]], i32* %[[DOTFLOOR_0_IV__FLOOR_0_IV_I18]], align 4
12707a6beb4SMichael Kruse // IR-NEXT:    %[[TMP23:.+]] = load i32, i32* %[[DOTFLOOR_0_IV__FLOOR_0_IV_I18]], align 4
12807a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[TMP23]], i32* %[[DOTTILE_0_IV__FLOOR_0_IV_I]], align 4
12907a6beb4SMichael Kruse // IR-NEXT:    br label %[[FOR_COND:.+]]
13007a6beb4SMichael Kruse // IR-EMPTY:
13107a6beb4SMichael Kruse // IR-NEXT:  [[FOR_COND]]:
13207a6beb4SMichael Kruse // IR-NEXT:    %[[TMP24:.+]] = load i32, i32* %[[DOTTILE_0_IV__FLOOR_0_IV_I]], align 4
13307a6beb4SMichael Kruse // IR-NEXT:    %[[TMP25:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_8]], align 4
13407a6beb4SMichael Kruse // IR-NEXT:    %[[ADD23:.+]] = add i32 %[[TMP25]], 1
13507a6beb4SMichael Kruse // IR-NEXT:    %[[TMP26:.+]] = load i32, i32* %[[DOTFLOOR_0_IV__FLOOR_0_IV_I18]], align 4
13607a6beb4SMichael Kruse // IR-NEXT:    %[[ADD24:.+]] = add i32 %[[TMP26]], 3
13707a6beb4SMichael Kruse // IR-NEXT:    %[[CMP25:.+]] = icmp ult i32 %[[ADD23]], %[[ADD24]]
13807a6beb4SMichael Kruse // IR-NEXT:    br i1 %[[CMP25]], label %[[COND_TRUE26:.+]], label %[[COND_FALSE28:.+]]
13907a6beb4SMichael Kruse // IR-EMPTY:
14007a6beb4SMichael Kruse // IR-NEXT:  [[COND_TRUE26]]:
14107a6beb4SMichael Kruse // IR-NEXT:    %[[TMP27:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_8]], align 4
14207a6beb4SMichael Kruse // IR-NEXT:    %[[ADD27:.+]] = add i32 %[[TMP27]], 1
14307a6beb4SMichael Kruse // IR-NEXT:    br label %[[COND_END30:.+]]
14407a6beb4SMichael Kruse // IR-EMPTY:
14507a6beb4SMichael Kruse // IR-NEXT:  [[COND_FALSE28]]:
14607a6beb4SMichael Kruse // IR-NEXT:    %[[TMP28:.+]] = load i32, i32* %[[DOTFLOOR_0_IV__FLOOR_0_IV_I18]], align 4
14707a6beb4SMichael Kruse // IR-NEXT:    %[[ADD29:.+]] = add i32 %[[TMP28]], 3
14807a6beb4SMichael Kruse // IR-NEXT:    br label %[[COND_END30]]
14907a6beb4SMichael Kruse // IR-EMPTY:
15007a6beb4SMichael Kruse // IR-NEXT:  [[COND_END30]]:
15107a6beb4SMichael Kruse // IR-NEXT:    %[[COND31:.+]] = phi i32 [ %[[ADD27]], %[[COND_TRUE26]] ], [ %[[ADD29]], %[[COND_FALSE28]] ]
15207a6beb4SMichael Kruse // IR-NEXT:    %[[CMP32:.+]] = icmp ult i32 %[[TMP24]], %[[COND31]]
15307a6beb4SMichael Kruse // IR-NEXT:    br i1 %[[CMP32]], label %[[FOR_BODY:.+]], label %[[FOR_END51:.+]]
15407a6beb4SMichael Kruse // IR-EMPTY:
15507a6beb4SMichael Kruse // IR-NEXT:  [[FOR_BODY]]:
15607a6beb4SMichael Kruse // IR-NEXT:    %[[TMP29:.+]] = load i32, i32* %[[DOTTILE_0_IV__FLOOR_0_IV_I]], align 4
15707a6beb4SMichael Kruse // IR-NEXT:    %[[MUL33:.+]] = mul i32 %[[TMP29]], 4
15807a6beb4SMichael Kruse // IR-NEXT:    %[[ADD34:.+]] = add i32 0, %[[MUL33]]
15907a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[ADD34]], i32* %[[DOTFLOOR_0_IV_I]], align 4
16007a6beb4SMichael Kruse // IR-NEXT:    %[[TMP30:.+]] = load i32, i32* %[[DOTFLOOR_0_IV_I]], align 4
16107a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[TMP30]], i32* %[[DOTTILE_0_IV_I]], align 4
16207a6beb4SMichael Kruse // IR-NEXT:    br label %[[FOR_COND35:.+]]
16307a6beb4SMichael Kruse // IR-EMPTY:
16407a6beb4SMichael Kruse // IR-NEXT:  [[FOR_COND35]]:
16507a6beb4SMichael Kruse // IR-NEXT:    %[[TMP31:.+]] = load i32, i32* %[[DOTTILE_0_IV_I]], align 4
16607a6beb4SMichael Kruse // IR-NEXT:    %[[TMP32:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
16707a6beb4SMichael Kruse // IR-NEXT:    %[[ADD36:.+]] = add i32 %[[TMP32]], 1
16807a6beb4SMichael Kruse // IR-NEXT:    %[[TMP33:.+]] = load i32, i32* %[[DOTFLOOR_0_IV_I]], align 4
16907a6beb4SMichael Kruse // IR-NEXT:    %[[ADD37:.+]] = add nsw i32 %[[TMP33]], 4
17007a6beb4SMichael Kruse // IR-NEXT:    %[[CMP38:.+]] = icmp ult i32 %[[ADD36]], %[[ADD37]]
17107a6beb4SMichael Kruse // IR-NEXT:    br i1 %[[CMP38]], label %[[COND_TRUE39:.+]], label %[[COND_FALSE41:.+]]
17207a6beb4SMichael Kruse // IR-EMPTY:
17307a6beb4SMichael Kruse // IR-NEXT:  [[COND_TRUE39]]:
17407a6beb4SMichael Kruse // IR-NEXT:    %[[TMP34:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_3]], align 4
17507a6beb4SMichael Kruse // IR-NEXT:    %[[ADD40:.+]] = add i32 %[[TMP34]], 1
17607a6beb4SMichael Kruse // IR-NEXT:    br label %[[COND_END43:.+]]
17707a6beb4SMichael Kruse // IR-EMPTY:
17807a6beb4SMichael Kruse // IR-NEXT:  [[COND_FALSE41]]:
17907a6beb4SMichael Kruse // IR-NEXT:    %[[TMP35:.+]] = load i32, i32* %[[DOTFLOOR_0_IV_I]], align 4
18007a6beb4SMichael Kruse // IR-NEXT:    %[[ADD42:.+]] = add nsw i32 %[[TMP35]], 4
18107a6beb4SMichael Kruse // IR-NEXT:    br label %[[COND_END43]]
18207a6beb4SMichael Kruse // IR-EMPTY:
18307a6beb4SMichael Kruse // IR-NEXT:  [[COND_END43]]:
18407a6beb4SMichael Kruse // IR-NEXT:    %[[COND44:.+]] = phi i32 [ %[[ADD40]], %[[COND_TRUE39]] ], [ %[[ADD42]], %[[COND_FALSE41]] ]
18507a6beb4SMichael Kruse // IR-NEXT:    %[[CMP45:.+]] = icmp ult i32 %[[TMP31]], %[[COND44]]
18607a6beb4SMichael Kruse // IR-NEXT:    br i1 %[[CMP45]], label %[[FOR_BODY46:.+]], label %[[FOR_END:.+]]
18707a6beb4SMichael Kruse // IR-EMPTY:
18807a6beb4SMichael Kruse // IR-NEXT:  [[FOR_BODY46]]:
18907a6beb4SMichael Kruse // IR-NEXT:    %[[TMP36:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_]], align 4
19007a6beb4SMichael Kruse // IR-NEXT:    %[[TMP37:.+]] = load i32, i32* %[[DOTTILE_0_IV_I]], align 4
19107a6beb4SMichael Kruse // IR-NEXT:    %[[TMP38:.+]] = load i32, i32* %[[DOTCAPTURE_EXPR_2]], align 4
19207a6beb4SMichael Kruse // IR-NEXT:    %[[MUL47:.+]] = mul i32 %[[TMP37]], %[[TMP38]]
19307a6beb4SMichael Kruse // IR-NEXT:    %[[ADD48:.+]] = add i32 %[[TMP36]], %[[MUL47]]
19407a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[ADD48]], i32* %[[I]], align 4
19507a6beb4SMichael Kruse // IR-NEXT:    %[[TMP39:.+]] = load i32, i32* %[[START_ADDR]], align 4
19607a6beb4SMichael Kruse // IR-NEXT:    %[[TMP40:.+]] = load i32, i32* %[[END_ADDR]], align 4
19707a6beb4SMichael Kruse // IR-NEXT:    %[[TMP41:.+]] = load i32, i32* %[[STEP_ADDR]], align 4
19807a6beb4SMichael Kruse // IR-NEXT:    %[[TMP42:.+]] = load i32, i32* %[[I]], align 4
19907a6beb4SMichael Kruse // IR-NEXT:    call void (...) @body(i32 %[[TMP39]], i32 %[[TMP40]], i32 %[[TMP41]], i32 %[[TMP42]])
20007a6beb4SMichael Kruse // IR-NEXT:    br label %[[FOR_INC:.+]]
20107a6beb4SMichael Kruse // IR-EMPTY:
20207a6beb4SMichael Kruse // IR-NEXT:  [[FOR_INC]]:
20307a6beb4SMichael Kruse // IR-NEXT:    %[[TMP43:.+]] = load i32, i32* %[[DOTTILE_0_IV_I]], align 4
20407a6beb4SMichael Kruse // IR-NEXT:    %[[INC:.+]] = add nsw i32 %[[TMP43]], 1
20507a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[INC]], i32* %[[DOTTILE_0_IV_I]], align 4
20607a6beb4SMichael Kruse // IR-NEXT:    br label %[[FOR_COND35]], !llvm.loop ![[LOOP2:[0-9]+]]
20707a6beb4SMichael Kruse // IR-EMPTY:
20807a6beb4SMichael Kruse // IR-NEXT:  [[FOR_END]]:
20907a6beb4SMichael Kruse // IR-NEXT:    br label %[[FOR_INC49:.+]]
21007a6beb4SMichael Kruse // IR-EMPTY:
21107a6beb4SMichael Kruse // IR-NEXT:  [[FOR_INC49]]:
21207a6beb4SMichael Kruse // IR-NEXT:    %[[TMP44:.+]] = load i32, i32* %[[DOTTILE_0_IV__FLOOR_0_IV_I]], align 4
21307a6beb4SMichael Kruse // IR-NEXT:    %[[INC50:.+]] = add i32 %[[TMP44]], 1
21407a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[INC50]], i32* %[[DOTTILE_0_IV__FLOOR_0_IV_I]], align 4
21507a6beb4SMichael Kruse // IR-NEXT:    br label %[[FOR_COND]], !llvm.loop ![[LOOP4:[0-9]+]]
21607a6beb4SMichael Kruse // IR-EMPTY:
21707a6beb4SMichael Kruse // IR-NEXT:  [[FOR_END51]]:
21807a6beb4SMichael Kruse // IR-NEXT:    br label %[[OMP_BODY_CONTINUE:.+]]
21907a6beb4SMichael Kruse // IR-EMPTY:
22007a6beb4SMichael Kruse // IR-NEXT:  [[OMP_BODY_CONTINUE]]:
22107a6beb4SMichael Kruse // IR-NEXT:    br label %[[OMP_INNER_FOR_INC:.+]]
22207a6beb4SMichael Kruse // IR-EMPTY:
22307a6beb4SMichael Kruse // IR-NEXT:  [[OMP_INNER_FOR_INC]]:
22407a6beb4SMichael Kruse // IR-NEXT:    %[[TMP45:.+]] = load i32, i32* %[[DOTOMP_IV]], align 4
22507a6beb4SMichael Kruse // IR-NEXT:    %[[ADD52:.+]] = add i32 %[[TMP45]], 1
22607a6beb4SMichael Kruse // IR-NEXT:    store i32 %[[ADD52]], i32* %[[DOTOMP_IV]], align 4
22707a6beb4SMichael Kruse // IR-NEXT:    br label %[[OMP_INNER_FOR_COND]]
22807a6beb4SMichael Kruse // IR-EMPTY:
22907a6beb4SMichael Kruse // IR-NEXT:  [[OMP_INNER_FOR_END]]:
23007a6beb4SMichael Kruse // IR-NEXT:    br label %[[OMP_LOOP_EXIT:.+]]
23107a6beb4SMichael Kruse // IR-EMPTY:
23207a6beb4SMichael Kruse // IR-NEXT:  [[OMP_LOOP_EXIT]]:
23307a6beb4SMichael Kruse // IR-NEXT:    call void @__kmpc_for_static_fini(%struct.ident_t* @1, i32 %[[TMP0]])
23407a6beb4SMichael Kruse // IR-NEXT:    br label %[[OMP_PRECOND_END]]
23507a6beb4SMichael Kruse // IR-EMPTY:
23607a6beb4SMichael Kruse // IR-NEXT:  [[OMP_PRECOND_END]]:
23707a6beb4SMichael Kruse // IR-NEXT:    call void @__kmpc_barrier(%struct.ident_t* @3, i32 %[[TMP0]])
23807a6beb4SMichael Kruse // IR-NEXT:    ret void
23907a6beb4SMichael Kruse // IR-NEXT:  }
24007a6beb4SMichael Kruse extern "C" void func(int start, int end, int step) {
24107a6beb4SMichael Kruse #pragma omp for
24207a6beb4SMichael Kruse #pragma omp tile sizes(3)
24307a6beb4SMichael Kruse #pragma omp tile sizes(4)
24407a6beb4SMichael Kruse   for (int i = start; i < end; i += step)
24507a6beb4SMichael Kruse     body(start, end, step, i);
24607a6beb4SMichael Kruse }
24707a6beb4SMichael Kruse 
24807a6beb4SMichael Kruse #endif /* HEADER */
24907a6beb4SMichael Kruse // IR: ![[META0:[0-9]+]] = !{i32 1, !"wchar_size", i32 4}
250*64e5a3bbSMichael Kruse // IR: ![[META1:[0-9]+]] = !{!"{{[^"]*}}"}
25107a6beb4SMichael Kruse // IR: ![[LOOP2]] = distinct !{![[LOOP2]], ![[LOOPPROP3:[0-9]+]]}
25207a6beb4SMichael Kruse // IR: ![[LOOPPROP3]] = !{!"llvm.loop.mustprogress"}
25307a6beb4SMichael Kruse // IR: ![[LOOP4]] = distinct !{![[LOOP4]], ![[LOOPPROP3]]}
254