Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / parallel_master_taskloop_simd_ast_print.cpp
blob441e16c268b1f9a3e6fc9253049d6b98490de4de
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP50
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP50
4 // RUN: %clang_cc1 -verify -fopenmp -DOMP51 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP51
5 // RUN: %clang_cc1 -fopenmp -DOMP51 -x c++ -std=c++11 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -fopenmp -DOMP51 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP51
8 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -DOMP5 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP50
9 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
10 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP50
11 // RUN: %clang_cc1 -verify -fopenmp-simd -DOMP51 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP51
12 // RUN: %clang_cc1 -fopenmp-simd -DOMP51 -x c++ -std=c++11 -emit-pch -o %t %s
13 // RUN: %clang_cc1 -fopenmp-simd -DOMP51 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP51
14 // expected-no-diagnostics
16 #ifndef HEADER
17 #define HEADER
19 void foo() {}
21 template <class T, int N>
22 T tmain(T argc) {
23 T b = argc, c, d, e, f, g;
24 static T a;
25 // CHECK: static T a;
26 #pragma omp taskgroup allocate(d) task_reduction(+: d)
27 #pragma omp parallel master taskloop simd if(taskloop: argc > N) default(shared) untied priority(N) grainsize(N) reduction(+:g) allocate(g) simdlen(8)
28 // CHECK-NEXT: #pragma omp taskgroup allocate(d) task_reduction(+: d)
29 // CHECK-NEXT: #pragma omp parallel master taskloop simd if(taskloop: argc > N) default(shared) untied priority(N) grainsize(N) reduction(+: g) allocate(g) simdlen(8){{$}}
30 for (int i = 0; i < 2; ++i)
31 a = 2;
32 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
33 // CHECK-NEXT: a = 2;
34 #pragma omp parallel
35 #pragma omp parallel master taskloop simd private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) shared(g) if (c) final(d) mergeable priority(f) nogroup num_tasks(N) safelen(8)
36 for (int i = 0; i < 2; ++i)
37 for (int j = 0; j < 2; ++j)
38 for (int j = 0; j < 2; ++j)
39 for (int j = 0; j < 2; ++j)
40 for (int j = 0; j < 2; ++j)
41 for (int i = 0; i < 2; ++i)
42 for (int j = 0; j < 2; ++j)
43 for (int j = 0; j < 2; ++j)
44 for (int j = 0; j < 2; ++j)
45 for (int j = 0; j < 2; ++j)
46 foo();
47 // CHECK-NEXT: #pragma omp parallel
48 // CHECK-NEXT: #pragma omp parallel master taskloop simd private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) nogroup num_tasks(N) safelen(8)
49 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
50 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
51 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
52 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
53 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
54 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
55 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
56 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
57 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
58 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
59 // CHECK-NEXT: foo();
60 return T();
63 // CHECK-LABEL: int main(int argc, char **argv) {
64 int main(int argc, char **argv) {
65 int b = argc, c, d, e, f, g, h;
66 static int a;
67 // CHECK: static int a;
68 #pragma omp taskgroup task_reduction(+: d)
69 #pragma omp parallel master taskloop simd if(parallel: a) default(none) shared(a, b, argc) final(b) priority(5) num_tasks(argc) reduction(*: g) aligned(argv: 8) linear(c:b)
70 // CHECK-NEXT: #pragma omp taskgroup task_reduction(+: d)
71 // CHECK-NEXT: #pragma omp parallel master taskloop simd if(parallel: a) default(none) shared(a,b,argc) final(b) priority(5) num_tasks(argc) reduction(*: g) aligned(argv: 8) linear(c: step(b))
72 for (int i = 0; i < 2; ++i)
73 a = 2;
74 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
75 // CHECK-NEXT: a = 2;
76 #pragma omp parallel
77 #ifdef OMP51
78 #pragma omp parallel master taskloop simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) shared(g) if(simd:argc) mergeable priority(argc) grainsize(argc) reduction(max: a, e) nontemporal(argc, c, d) order(reproducible:concurrent)
79 #elif OMP5
80 #pragma omp parallel master taskloop simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) shared(g) if(simd:argc) mergeable priority(argc) grainsize(argc) reduction(max: a, e) nontemporal(argc, c, d) order(concurrent)
81 #else
82 #pragma omp parallel master taskloop simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) shared(g) if(argc) mergeable priority(argc) grainsize(argc) reduction(max: a, e)
83 #endif // OMP51
84 for (int i = 0; i < 10; ++i)
85 for (int j = 0; j < 10; ++j)
86 foo();
87 // CHECK-NEXT: #pragma omp parallel
88 // OMP50-NEXT: #pragma omp parallel master taskloop simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) shared(g) if(simd: argc) mergeable priority(argc) grainsize(argc) reduction(max: a,e) nontemporal(argc,c,d) order(concurrent)
89 // OMP51-NEXT: #pragma omp parallel master taskloop simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) shared(g) if(simd: argc) mergeable priority(argc) grainsize(argc) reduction(max: a,e) nontemporal(argc,c,d) order(reproducible: concurrent)
90 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
91 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
92 // CHECK-NEXT: foo();
93 return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
96 #endif