Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / target_update_ast_print.cpp
blobbe00c4fd9fb29b3c64e2e1ebee724b8eea052a25
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
5 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
9 // RUN: %clang_cc1 -DOMP51 -verify -fopenmp -ast-print %s | FileCheck -check-prefixes=CHECK,OMP51 %s
10 // RUN: %clang_cc1 -DOMP51 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
11 // RUN: %clang_cc1 -DOMP51 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck -check-prefixes=CHECK,OMP51 %s
13 // RUN: %clang_cc1 -DOMP51 -verify -fopenmp-simd -ast-print %s | FileCheck -check-prefixes=CHECK,OMP51 %s
14 // RUN: %clang_cc1 -DOMP51 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
15 // RUN: %clang_cc1 -DOMP51 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck -check-prefixes=CHECK,OMP51 %s
16 // expected-no-diagnostics
18 #ifndef HEADER
19 #define HEADER
21 void foo() {}
23 template <class T, class U>
24 T foo(T targ, U uarg) {
25 static T a, *p;
26 U b;
27 int l;
28 #pragma omp target update to(([a][targ])p, a) if(l>5) device(l) nowait depend(inout:l)
30 #pragma omp target update from(b, ([a][targ])p) if(l<5) device(l-1) nowait depend(inout:l)
32 U marr[10][10][10];
33 #pragma omp target update to(marr[2][0:2][0:2])
35 #pragma omp target update from(marr[2][0:2][0:2])
37 #pragma omp target update from(marr[:2][0:2][0:2:1])
39 #pragma omp target update to(marr[:l][:l][l:])
41 #pragma omp target update to(marr[:2][:1][:])
43 #pragma omp target update from(marr[:2][:1][:])
45 #pragma omp target update to(marr[:2][:][:1])
47 #pragma omp target update from(marr[:2][:][:1])
49 #pragma omp target update to(marr[:2][:] [1:])
51 #pragma omp target update from(marr[:2][:][1:])
53 #pragma omp target update to(marr[:1][3:2][:2])
55 #pragma omp target update from(marr[:1][3:2][:2])
57 #pragma omp target update to(marr[:1][:2][0])
59 #pragma omp target update from(marr[:1][:2][0])
61 int arr[100][100];
62 #pragma omp target update to(arr[2][0:1:2])
64 #pragma omp target update from(arr[2][0:1:2])
66 #ifdef OMP51
67 #pragma omp target update to(present: arr[2][0:1:2])
69 #pragma omp target update from(present: arr[2][0:1:2], a)
70 #endif
72 return a + targ + (T)b;
74 // CHECK: static T a, *p;
75 // CHECK-NEXT: U b;
76 // CHECK-NEXT: int l;
77 // CHECK-NEXT: #pragma omp target update to(([a][targ])p,a) if(l > 5) device(l) nowait depend(inout : l){{$}}
78 // CHECK-NEXT: #pragma omp target update from(b,([a][targ])p) if(l < 5) device(l - 1) nowait depend(inout : l)
79 // CHECK: static int a, *p;
80 // CHECK-NEXT: float b;
81 // CHECK-NEXT: int l;
82 // CHECK-NEXT: #pragma omp target update to(([a][targ])p,a) if(l > 5) device(l) nowait depend(inout : l)
83 // CHECK-NEXT: #pragma omp target update from(b,([a][targ])p) if(l < 5) device(l - 1) nowait depend(inout : l)
84 // CHECK: static char a, *p;
85 // CHECK-NEXT: float b;
86 // CHECK-NEXT: int l;
87 // CHECK-NEXT: #pragma omp target update to(([a][targ])p,a) if(l > 5) device(l) nowait depend(inout : l)
88 // CHECK-NEXT: #pragma omp target update from(b,([a][targ])p) if(l < 5) device(l - 1) nowait depend(inout : l)
89 // CHECK: marr[10][10][10];
90 // CHECK-NEXT: #pragma omp target update to(marr[2][0:2][0:2])
91 // CHECK-NEXT: #pragma omp target update from(marr[2][0:2][0:2])
92 // CHECK-NEXT: #pragma omp target update from(marr[:2][0:2][0:2:1])
93 // CHECK-NEXT: #pragma omp target update to(marr[:l][:l][l:])
94 // CHECK-NEXT: #pragma omp target update to(marr[:2][:1][:])
95 // CHECK-NEXT: #pragma omp target update from(marr[:2][:1][:])
96 // CHECK-NEXT: #pragma omp target update to(marr[:2][:][:1])
97 // CHECK-NEXT: #pragma omp target update from(marr[:2][:][:1])
98 // CHECK-NEXT: #pragma omp target update to(marr[:2][:][1:])
99 // CHECK-NEXT: #pragma omp target update from(marr[:2][:][1:])
100 // CHECK-NEXT: #pragma omp target update to(marr[:1][3:2][:2])
101 // CHECK-NEXT: #pragma omp target update from(marr[:1][3:2][:2])
102 // CHECK-NEXT: #pragma omp target update to(marr[:1][:2][0])
103 // CHECK-NEXT: #pragma omp target update from(marr[:1][:2][0])
104 // CHECK: int arr[100][100];
105 // CHECK-NEXT: #pragma omp target update to(arr[2][0:1:2])
106 // CHECK-NEXT: #pragma omp target update from(arr[2][0:1:2])
107 // OMP5-NEXT: #pragma omp target update to(present: arr[2][0:1:2])
108 // OMP5-NEXT: #pragma omp target update from(present: arr[2][0:1:2], a)
110 int main(int argc, char **argv) {
111 static int a;
112 int n;
113 float f;
115 // CHECK: static int a;
116 // CHECK-NEXT: int n;
117 // CHECK-NEXT: float f;
118 #pragma omp target update to(a) if(f>0.0) device(n) nowait depend(in:n)
119 // CHECK-NEXT: #pragma omp target update to(a) if(f > 0.) device(n) nowait depend(in : n)
120 #pragma omp target update from(f) if(f<0.0) device(n+1) nowait depend(in:n)
121 // CHECK-NEXT: #pragma omp target update from(f) if(f < 0.) device(n + 1) nowait depend(in : n)
122 #pragma omp target update to(argv[2][0:1:2])
123 // CHECK-NEXT: #pragma omp target update to(argv[2][0:1:2])
124 #pragma omp target update from(argv[2][0:1:2])
125 // CHECK-NEXT: #pragma omp target update from(argv[2][0:1:2])
126 #ifdef OMP51
127 #pragma omp target update to(present: argv[2][0:1:2])
128 // OMP5-NEXT: #pragma omp target update to(present: arr[2][0:1:2])
129 #pragma omp target update from(argv[2][0:1:2], a)
130 // OMP5-NEXT: #pragma omp target update from(present: arr[2][0:1:2], a)
131 #endif
133 float marr[10][10][10];
134 // CHECK: marr[10][10][10];
135 #pragma omp target update to(marr[2][0:2][0:2])
136 // CHECK-NEXT: #pragma omp target update to(marr[2][0:2][0:2])
137 #pragma omp target update from(marr[2][0:2][0:2])
138 // CHECK-NEXT: #pragma omp target update from(marr[2][0:2][0:2])
139 #pragma omp target update to(marr[:n][:n][n:])
140 // CHECK: #pragma omp target update to(marr[:n][:n][n:])
141 #pragma omp target update from(marr[:2][:1][:])
142 // CHECK-NEXT: #pragma omp target update from(marr[:2][:1][:])
143 #pragma omp target update to(marr[:2][:][:1])
144 // CHECK-NEXT: #pragma omp target update to(marr[:2][:][:1])
145 #pragma omp target update from(marr[:2][:][:1])
146 // CHECK-NEXT: #pragma omp target update from(marr[:2][:][:1])
147 #pragma omp target update to(marr[:2][:][1:])
148 // CHECK-NEXT: #pragma omp target update to(marr[:2][:][1:])
149 #pragma omp target update from(marr[:2][:][1:])
150 // CHECK-NEXT: #pragma omp target update from(marr[:2][:][1:])
151 #pragma omp target update to(marr[:1][3:2][:2])
152 // CHECK-NEXT: #pragma omp target update to(marr[:1][3:2][:2])
153 #pragma omp target update from(marr[:1][3:2][:2])
154 // CHECK-NEXT: #pragma omp target update from(marr[:1][3:2][:2])
155 #pragma omp target update to(marr[:1][:2][0])
156 // CHECK-NEXT: #pragma omp target update to(marr[:1][:2][0])
157 #pragma omp target update from(marr[:1][:2][0])
158 // CHECK-NEXT: #pragma omp target update from(marr[:1][:2][0])
159 #pragma omp target update to(marr[:2:][0:2][0:2:1])
160 // CHECK-NEXT: #pragma omp target update to(marr[:2:][0:2][0:2:1])
161 #pragma omp target update from(marr[:2:][0:2][0:2:1])
162 // CHECK-NEXT: #pragma omp target update from(marr[:2:][0:2][0:2:1])
163 #pragma omp target update to(marr[:2:][:2:][0:2:1])
164 // CHECK-NEXT: #pragma omp target update to(marr[:2:][:2:][0:2:1])
165 #pragma omp target update from(marr[:2:][:2:][0:2:1])
166 // CHECK-NEXT: #pragma omp target update from(marr[:2:][:2:][0:2:1])
168 return foo(argc, f) + foo(argv[0][0], f) + a;
171 #endif