1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
4 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
5 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5
6 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
7 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
8 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51
9 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
10 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 -ast-print %s -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
11 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP52
12 // RUN: %clang_cc1 -fopenmp -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
14 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
15 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
16 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix=CHECK --check-prefix=OMP45
17 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
18 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5
19 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP5 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP50
20 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
21 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -DOMP51
22 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP51 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP51
23 // expected-no-diagnostics
24 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -ast-print %s -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
25 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP52
26 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print -DOMP52 | FileCheck %s --check-prefix=CHECK --check-prefix=OMP52
27 // expected-no-diagnostics
47 S7(typename
T::type
&v
) : a((T
*)&v
) {
48 #pragma omp simd aligned(a)
49 for (int k
= 0; k
< a
->a
; ++k
)
52 S7
&operator=(S7
&s
) {
53 #pragma omp simd aligned(this->b : 8)
54 for (int k
= 0; k
< s
.a
->a
; ++k
)
60 // CHECK: #pragma omp simd aligned(this->a){{$}}
61 // CHECK: #pragma omp simd aligned(this->b: 8)
62 // CHECK: #pragma omp simd aligned(this->a)
64 class S8
: public S7
<SS
> {
68 S8(int v
) : S7
<SS
>(v
){
69 #pragma omp simd aligned(S7<SS>::a)
70 for (int k
= 0; k
< a
->a
; ++k
)
73 S8
&operator=(S8
&s
) {
74 #pragma omp simd aligned(this->b: 4)
75 for (int k
= 0; k
< s
.a
->a
; ++k
)
81 // CHECK: #pragma omp simd aligned(this->S7<SS>::a)
82 // CHECK: #pragma omp simd aligned(this->b: 4)
86 template<class T
, class N
> T
reduct(T
* arr
, N num
) {
92 // CHECK: T sum = (T)0;
94 #pragma omp simd private(myind, g_ind), linear(ind), aligned(arr), linear(r: uval)
96 #pragma omp simd private(myind, g_ind), linear(ind), aligned(arr), linear(uval(r))
98 // CHECK-NEXT: #pragma omp simd private(myind,g_ind) linear(ind) aligned(arr) linear(r: uval)
99 for (i
= 0; i
< num
; ++i
) {
107 template<class T
> struct S
{
111 T
result(T
*v
) const {
119 // CHECK: T &r = res;
121 #pragma omp simd allocate(res) private(val) safelen(7) linear(lin : step(-5)) lastprivate(res) simdlen(5) linear(r: ref)
123 #pragma omp simd allocate(res) private(val) safelen(7) linear(lin : -5) lastprivate(res) simdlen(5) linear(ref(r))
125 // CHECK-NEXT: #pragma omp simd allocate(res) private(val) safelen(7) linear(lin: step(-5)) lastprivate(res) simdlen(5) linear(r: ref)
126 for (T i
= 7; i
< m_a
; ++i
) {
132 // CHECK: T clen = 3;
133 #pragma omp simd safelen(clen-1) simdlen(clen-1)
134 // CHECK-NEXT: #pragma omp simd safelen(clen - 1) simdlen(clen - 1)
135 for(T i
= clen
+2; i
< 20; ++i
) {
136 // CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {
137 v
[i
] = v
[v
-clen
] + 1;
138 // CHECK-NEXT: v[i] = v[v - clen] + 1;
148 template<int LEN
> struct S2
{
149 static void func(int n
, float *a
, float *b
, float *c
) {
151 #pragma omp simd safelen(LEN) linear(k1,k2:LEN) aligned(a:LEN) simdlen(LEN) allocate(k1)
152 for(int i
= 0; i
< n
; i
++) {
154 c
[k1
] = a
[k1
] + b
[k1
];
155 c
[k2
] = a
[k2
] + b
[k2
];
162 // S2<4>::func is called below in main.
163 // CHECK: template<> struct S2<4> {
164 // CHECK-NEXT: static void func(int n, float *a, float *b, float *c) {
165 // CHECK-NEXT: int k1 = 0, k2 = 0;
166 // CHECK-NEXT: #pragma omp simd safelen(4) linear(k1,k2: step(4)) aligned(a: 4) simdlen(4) allocate(k1)
167 // CHECK-NEXT: for (int i = 0; i < n; i++) {
168 // CHECK-NEXT: c[i] = a[i] + b[i];
169 // CHECK-NEXT: c[k1] = a[k1] + b[k1];
170 // CHECK-NEXT: c[k2] = a[k2] + b[k2];
171 // CHECK-NEXT: k1 = k1 + 4;
172 // CHECK-NEXT: k2 = k2 + 4;
176 int main (int argc
, char **argv
) {
177 int b
= argc
, c
, d
, e
, f
, g
;
181 // CHECK: static int *a;
183 // CHECK-NEXT: #pragma omp simd{{$}}
184 for (int i
=0; i
< 2; ++i
)*a
=2;
185 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
186 // CHECK-NEXT: *a = 2;
188 #pragma omp simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) if(simd:a) nontemporal(argc, c, d) lastprivate(conditional: e, f) order(unconstrained:concurrent)
189 // OMP52-NEXT: #pragma omp simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) if(simd: a) nontemporal(argc,c,d) lastprivate(conditional: e,f) order(unconstrained: concurrent)
191 #pragma omp simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) if(simd:a) nontemporal(argc, c, d) lastprivate(conditional: e, f) order(unconstrained:concurrent)
192 // OMP51-NEXT: #pragma omp simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) if(simd: a) nontemporal(argc,c,d) lastprivate(conditional: e,f) order(unconstrained: concurrent)
194 #pragma omp simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) if(simd:a) nontemporal(argc, c, d) lastprivate(conditional: e, f) order(concurrent)
195 // OMP50-NEXT: #pragma omp simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) if(simd: a) nontemporal(argc,c,d) lastprivate(conditional: e,f) order(concurrent)
197 #pragma omp simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4)
198 // OMP45-NEXT: #pragma omp simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4)
200 for (int i
= 0; i
< 10; ++i
)
201 for (int j
= 0; j
< 10; ++j
) {foo(); k1
+= 8; k2
+= 8;}
202 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
203 // CHECK-NEXT: for (int j = 0; j < 10; ++j) {
204 // CHECK-NEXT: foo();
205 // CHECK-NEXT: k1 += 8;
206 // CHECK-NEXT: k2 += 8;
208 for (int i
= 0; i
< 10; ++i
)foo();
209 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
210 // CHECK-NEXT: foo();
212 // CHECK-NEXT: const int CLEN = 4;
214 #pragma omp simd aligned(a:CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse( 1 ) simdlen(CLEN) linear(r: val, step(CLEN)) if(a)
216 #pragma omp simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) simdlen(CLEN) linear(val(r): CLEN) if(a)
217 // OMP50-NEXT: #pragma omp simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN) linear(r: val, step(CLEN)) if(a)
219 #pragma omp simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 ) simdlen(CLEN) linear(val(r): CLEN)
220 // OMP45-NEXT: #pragma omp simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN) linear(r: val, step(CLEN))
221 // OMP51-NEXT: #pragma omp simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN) linear(r: val, step(CLEN))
222 // OMP52-NEXT: #pragma omp simd aligned(a: CLEN) linear(a: step(CLEN)) safelen(CLEN) collapse(1) simdlen(CLEN) linear(r: val, step(CLEN))
224 for (int i
= 0; i
< 10; ++i
)foo();
225 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
226 // CHECK-NEXT: foo();
229 S2
<4>::func(0,arr
,arr
,arr
);