1; RUN: opt %loadPolly -polly-codegen -polly-parallel -S < %s | FileCheck %s --check-prefix=AUTO
2; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-num-threads=1 -S < %s | FileCheck %s --check-prefix=ONE
3; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-num-threads=4 -S < %s | FileCheck %s --check-prefix=FOUR
4
5; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-omp-backend=LLVM -S < %s | FileCheck %s --check-prefix=LIBOMP-AUTO
6; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-omp-backend=LLVM -polly-num-threads=1 -S < %s | FileCheck %s --check-prefix=LIBOMP-ONE
7; RUN: opt %loadPolly -polly-codegen -polly-parallel -polly-omp-backend=LLVM -polly-num-threads=4 -S < %s | FileCheck %s --check-prefix=LIBOMP-FOUR
8
9; Ensure that the provided thread numbers are forwarded to the OpenMP calls.
10;
11;    void storePosition(int *A) {
12;      for (int i = 0; i < 1024; i++)
13;        for (int j = 0; j < 1024; j++)
14;          A[i + j * 1024] = 0;
15;    }
16
17; AUTO: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @storePosition_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 0, i64 0, i64 1024, i64 1)
18; ONE: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @storePosition_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 1, i64 0, i64 1024, i64 1)
19; FOUR: call void @GOMP_parallel_loop_runtime_start(void (i8*)* @storePosition_polly_subfn, i8* %polly.par.userContext{{[0-9]*}}, i32 4, i64 0, i64 1024, i64 1)
20
21; In automatic mode, no threads are pushed explicitly.
22; LIBOMP-AUTO-NOT: call void @__kmpc_push_num_threads
23; LIBOMP-ONE: call void @__kmpc_push_num_threads(%struct.ident_t* @.loc.dummy{{[.0-9]*}}, i32 %{{[0-9]+}}, i32 1)
24; LIBOMP-FOUR: call void @__kmpc_push_num_threads(%struct.ident_t* @.loc.dummy{{[.0-9]*}}, i32 %{{[0-9]+}}, i32 4)
25
26target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
27
28define void @storePosition(i32* %A) {
29entry:
30  br label %for.cond
31
32for.cond:                                         ; preds = %for.inc4, %entry
33  %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc4 ], [ 0, %entry ]
34  %exitcond5 = icmp ne i64 %indvars.iv3, 1024
35  br i1 %exitcond5, label %for.body, label %for.end6
36
37for.body:                                         ; preds = %for.cond
38  br label %for.cond1
39
40for.cond1:                                        ; preds = %for.inc, %for.body
41  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body ]
42  %exitcond = icmp ne i64 %indvars.iv, 1024
43  br i1 %exitcond, label %for.body3, label %for.end
44
45for.body3:                                        ; preds = %for.cond1
46  %tmp = shl nsw i64 %indvars.iv, 10
47  %tmp6 = add nsw i64 %indvars.iv3, %tmp
48  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %tmp6
49  store i32 0, i32* %arrayidx, align 4
50  br label %for.inc
51
52for.inc:                                          ; preds = %for.body3
53  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
54  br label %for.cond1
55
56for.end:                                          ; preds = %for.cond1
57  br label %for.inc4
58
59for.inc4:                                         ; preds = %for.end
60  %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1
61  br label %for.cond
62
63for.end6:                                         ; preds = %for.cond
64  ret void
65}
66