Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / PCH / pragma-loop.cpp
blobf5de630ffc91206b4bf3b59cf481994a6eaefb9b
1 // RUN: %clang_cc1 -fopenmp -emit-pch -o %t.a %s
2 // RUN: %clang_cc1 -fopenmp -include-pch %t.a %s -ast-print -o - | FileCheck %s
4 // CHECK: #pragma clang loop vectorize_width(4)
5 // CHECK: #pragma clang loop interleave_count(8)
6 // CHECK: #pragma clang loop unroll_count(16){{$}}
7 // CHECK: #pragma clang loop vectorize(enable)
8 // CHECK: #pragma clang loop interleave(disable)
9 // CHECK: #pragma clang loop unroll(disable)
10 // CHECK: #pragma clang loop distribute(enable)
11 // CHECK: #pragma clang loop vectorize(disable)
12 // CHECK: #pragma clang loop interleave(enable)
13 // CHECK: #pragma clang loop unroll(full)
14 // CHECK: #pragma clang loop distribute(disable)
15 // FIXME: "#pragma unroll (enable)" is invalid and is not the input source.
16 // CHECK: #pragma unroll (enable){{$}}
17 // CHECK: #pragma unroll (32){{$}}
18 // CHECK: #pragma nounroll{{$}}
19 // CHECK: #pragma clang loop vectorize_width(V)
20 // CHECK: #pragma clang loop interleave_count(I)
21 // CHECK: #pragma omp simd
22 // CHECK: #pragma omp for
23 // CHECK: #pragma omp distribute
25 #ifndef HEADER
26 #define HEADER
28 class pragma_test {
29 public:
30 inline void run1(int *List, int Length) {
31 int i = 0;
32 #pragma clang loop vectorize_width(4)
33 #pragma clang loop interleave_count(8)
34 #pragma clang loop unroll_count(16)
35 while (i < Length) {
36 List[i] = i;
37 i++;
41 inline void run2(int *List, int Length) {
42 int i = 0;
43 #pragma clang loop vectorize(enable)
44 #pragma clang loop interleave(disable)
45 #pragma clang loop unroll(disable)
46 #pragma clang loop distribute(enable)
47 while (i - 1 < Length) {
48 List[i] = i;
49 i++;
53 inline void run3(int *List, int Length) {
54 int i = 0;
55 #pragma clang loop vectorize(disable)
56 #pragma clang loop interleave(enable)
57 #pragma clang loop unroll(full)
58 #pragma clang loop distribute(disable)
59 while (i - 3 < Length) {
60 List[i] = i;
61 i++;
65 inline void run4(int *List, int Length) {
66 int i = 0;
67 #pragma unroll
68 while (i - 3 < Length) {
69 List[i] = i;
70 i++;
74 inline void run5(int *List, int Length) {
75 int i = 0;
76 #pragma unroll 32
77 while (i - 3 < Length) {
78 List[i] = i;
79 i++;
83 inline void run6(int *List, int Length) {
84 int i = 0;
85 #pragma nounroll
86 while (i - 3 < Length) {
87 List[i] = i;
88 i++;
92 template <int V, int I>
93 inline void run7(int *List, int Length) {
94 #pragma clang loop vectorize_width(V)
95 #pragma clang loop interleave_count(I)
96 for (int i = 0; i < Length; i++) {
97 List[i] = i;
101 inline void run8(int *List, int Length) {
102 int i = 0;
103 #pragma omp loop bind(thread)
104 for (int i = 0; i < Length; i++) {
105 List[i] = i;
109 inline void run9(int *List, int Length) {
110 int i = 0;
111 #pragma omp loop bind(parallel)
112 for (int i = 0; i < Length; i++) {
113 List[i] = i;
117 inline void run10(int *List, int Length) {
118 int i = 0;
119 #pragma omp loop bind(teams)
120 for (int i = 0; i < Length; i++) {
121 List[i] = i;
126 #else
127 void test() {
128 int List[100];
130 pragma_test pt;
132 pt.run1(List, 100);
133 pt.run2(List, 100);
134 pt.run3(List, 100);
135 pt.run4(List, 100);
136 pt.run5(List, 100);
137 pt.run6(List, 100);
138 pt.run7<2, 4>(List, 100);
139 pt.run8(List, 100);
140 pt.run9(List, 100);
141 pt.run10(List, 100);
144 #endif