Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / ordered_ast_print.cpp
blobe64c22abc3c7ebb4baa987811756bae58080dd04
1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck -check-prefixes CHECK,OMP51 %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck -check-prefixes CHECK,OMP51 %s
5 // RUN: %clang_cc1 -verify -fopenmp-version=52 -fopenmp -ast-print %s | FileCheck -check-prefixes CHECK,OMP52 %s
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck -check-prefixes CHECK,OMP52 %s
9 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck -check-prefixes CHECK,OMP51 %s
10 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
11 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck -check-prefixes CHECK,OMP51 %s
12 // expected-no-diagnostics
14 #ifndef HEADER
15 #define HEADER
17 void foo() {}
19 template <class T, int N>
20 T tmain (T argc) {
21 T b = argc, c, d, e, f, g;
22 static T a;
23 #pragma omp for ordered
24 for (int i =0 ; i < argc; ++i)
25 #pragma omp ordered
27 a=2;
29 #pragma omp for ordered
30 for (int i =0 ; i < argc; ++i)
31 #pragma omp ordered threads
33 a=2;
35 #pragma omp simd
36 for (int i =0 ; i < argc; ++i)
37 #pragma omp ordered simd
39 a=2;
41 #pragma omp for simd
42 for (int i =0 ; i < argc; ++i)
43 #pragma omp ordered simd
45 a=2;
47 #pragma omp parallel for simd
48 for (int i =0 ; i < argc; ++i)
49 #pragma omp ordered simd
51 a=2;
53 #pragma omp parallel for ordered(1)
54 for (int i =0 ; i < argc; ++i) {
55 #if _OPENMP >= 202111
56 #pragma omp ordered doacross(source:)
57 #pragma omp ordered doacross(sink:i+N)
58 #pragma omp ordered doacross(sink: omp_cur_iteration - 1)
59 #pragma omp ordered doacross(source: omp_cur_iteration)
60 #else
61 #pragma omp ordered depend(source)
62 #pragma omp ordered depend(sink:i+N)
63 #endif
64 a = 2;
66 return (0);
69 // CHECK: static T a;
70 // CHECK-NEXT: #pragma omp for ordered
71 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
72 // CHECK-NEXT: #pragma omp ordered{{$}}
73 // CHECK-NEXT: {
74 // CHECK-NEXT: a = 2;
75 // CHECK-NEXT: }
76 // CHECK-NEXT: #pragma omp for ordered
77 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
78 // CHECK-NEXT: #pragma omp ordered threads
79 // CHECK-NEXT: {
80 // CHECK-NEXT: a = 2;
81 // CHECK-NEXT: }
82 // CHECK-NEXT: #pragma omp simd
83 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
84 // CHECK-NEXT: #pragma omp ordered simd
85 // CHECK-NEXT: {
86 // CHECK-NEXT: a = 2;
87 // CHECK-NEXT: }
88 // CHECK-NEXT: #pragma omp for simd
89 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
90 // CHECK-NEXT: #pragma omp ordered simd
91 // CHECK-NEXT: {
92 // CHECK-NEXT: a = 2;
93 // CHECK-NEXT: }
94 // CHECK-NEXT: #pragma omp parallel for simd
95 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
96 // CHECK-NEXT: #pragma omp ordered simd
97 // CHECK-NEXT: {
98 // CHECK-NEXT: a = 2;
99 // CHECK-NEXT: }
100 // CHECK-NEXT: #pragma omp parallel for ordered(1)
101 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
102 #if _OPENMP >= 202111
103 // OMP52: #pragma omp ordered doacross(source:)
104 // OMP52-NEXT: #pragma omp ordered doacross(sink: i + N)
105 // OMP52-NEXT: #pragma omp ordered doacross(sink: omp_cur_iteration - 1)
106 // OMP52-NEXT: #pragma omp ordered doacross(source: omp_cur_iteration)
107 #else
108 // OMP51: #pragma omp ordered depend(source)
109 // OMP51-NEXT: #pragma omp ordered depend(sink : i + N)
110 #endif
111 // CHECK-NEXT: a = 2;
112 // CHECK-NEXT: }
113 // CHECK: static int a;
114 // CHECK-NEXT: #pragma omp for ordered
115 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
116 // CHECK-NEXT: #pragma omp ordered
117 // CHECK-NEXT: {
118 // CHECK-NEXT: a = 2;
119 // CHECK-NEXT: }
120 // CHECK-NEXT: #pragma omp for ordered
121 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
122 // CHECK-NEXT: #pragma omp ordered threads
123 // CHECK-NEXT: {
124 // CHECK-NEXT: a = 2;
125 // CHECK-NEXT: }
126 // CHECK-NEXT: #pragma omp simd
127 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
128 // CHECK-NEXT: #pragma omp ordered simd
129 // CHECK-NEXT: {
130 // CHECK-NEXT: a = 2;
131 // CHECK-NEXT: }
132 // CHECK-NEXT: #pragma omp for simd
133 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
134 // CHECK-NEXT: #pragma omp ordered simd
135 // CHECK-NEXT: {
136 // CHECK-NEXT: a = 2;
137 // CHECK-NEXT: }
138 // CHECK-NEXT: #pragma omp parallel for simd
139 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
140 // CHECK-NEXT: #pragma omp ordered simd
141 // CHECK-NEXT: {
142 // CHECK-NEXT: a = 2;
143 // CHECK-NEXT: }
144 // CHECK-NEXT: #pragma omp parallel for ordered(1)
145 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
146 #if _OPENMP >= 202111
147 // OMP52: #pragma omp ordered doacross(source:)
148 // OMP52-NEXT: #pragma omp ordered doacross(sink: i + 3)
149 // OMP52-NEXT: #pragma omp ordered doacross(sink: omp_cur_iteration - 1)
150 // OMP52-NEXT: #pragma omp ordered doacross(source: omp_cur_iteration)
151 #else
152 // OMP51: #pragma omp ordered depend(source)
153 // OMP51-NEXT: #pragma omp ordered depend(sink : i + 3)
154 #endif
155 // CHECK-NEXT: a = 2;
156 // CHECK-NEXT: }
158 // CHECK-LABEL: int main(
159 int main (int argc, char **argv) {
160 int b = argc, c, d, e, f, g;
161 static int a;
162 // CHECK: static int a;
163 #pragma omp for ordered
164 for (int i =0 ; i < argc; ++i)
165 #pragma omp ordered
167 a=2;
169 #pragma omp for ordered
170 for (int i =0 ; i < argc; ++i)
171 #pragma omp ordered threads
173 a=2;
175 #pragma omp simd
176 for (int i =0 ; i < argc; ++i)
177 #pragma omp ordered simd
179 a=2;
181 #pragma omp for simd
182 for (int i =0 ; i < argc; ++i)
183 #pragma omp ordered simd
185 a=2;
187 #pragma omp parallel for simd
188 for (int i =0 ; i < argc; ++i)
189 #pragma omp ordered simd
191 a=2;
193 #pragma omp parallel for ordered(1)
194 for (int i =0 ; i < argc; ++i) {
195 #if _OPENMP >= 202111
196 #pragma omp ordered doacross(source:)
197 #pragma omp ordered doacross(sink: i - 5)
198 #pragma omp ordered doacross(sink: omp_cur_iteration - 1)
199 #pragma omp ordered doacross(source: omp_cur_iteration)
200 #else
201 #pragma omp ordered depend(source)
202 #pragma omp ordered depend(sink: i - 5)
203 #endif
204 a = 2;
206 // CHECK-NEXT: #pragma omp for ordered
207 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
208 // CHECK-NEXT: #pragma omp ordered
209 // CHECK-NEXT: {
210 // CHECK-NEXT: a = 2;
211 // CHECK-NEXT: }
212 // CHECK-NEXT: #pragma omp for ordered
213 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
214 // CHECK-NEXT: #pragma omp ordered threads
215 // CHECK-NEXT: {
216 // CHECK-NEXT: a = 2;
217 // CHECK-NEXT: }
218 // CHECK-NEXT: #pragma omp simd
219 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
220 // CHECK-NEXT: #pragma omp ordered simd
221 // CHECK-NEXT: {
222 // CHECK-NEXT: a = 2;
223 // CHECK-NEXT: }
224 // CHECK-NEXT: #pragma omp for simd
225 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
226 // CHECK-NEXT: #pragma omp ordered simd
227 // CHECK-NEXT: {
228 // CHECK-NEXT: a = 2;
229 // CHECK-NEXT: }
230 // CHECK-NEXT: #pragma omp parallel for simd
231 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
232 // CHECK-NEXT: #pragma omp ordered simd
233 // CHECK-NEXT: {
234 // CHECK-NEXT: a = 2;
235 // CHECK-NEXT: }
236 // CHECK-NEXT: #pragma omp parallel for ordered(1)
237 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
238 #if _OPENMP >= 202111
239 // OMP52: #pragma omp ordered doacross(source:)
240 // OMP52-NEXT: #pragma omp ordered doacross(sink: i - 5)
241 // OMP52-NEXT: #pragma omp ordered doacross(sink: omp_cur_iteration - 1)
242 // OMP52-NEXT: #pragma omp ordered doacross(source: omp_cur_iteration)
243 #else
244 // OMP51: #pragma omp ordered depend(source)
245 // OMP51-NEXT: #pragma omp ordered depend(sink : i - 5)
246 #endif
247 // CHECK-NEXT: a = 2;
248 // CHECK-NEXT: }
249 return tmain<int, 3>(argc);
252 #endif