1 // RUN: %clang_cc1 -emit-pch -o %t.a %s
2 // RUN: %clang_cc1 -include-pch %t.a %s -ast-print -o - | FileCheck %s
3 
4 // FIXME: A bug in ParsedAttributes causes the order of the attributes to be
5 // reversed. The checks are consequently in the reverse order below.
6 
7 // CHECK: #pragma clang loop unroll_count(16)
8 // CHECK: #pragma clang loop interleave_count(8)
9 // CHECK: #pragma clang loop vectorize_width(4)
10 // CHECK: #pragma clang loop distribute(enable)
11 // CHECK: #pragma clang loop unroll(disable)
12 // CHECK: #pragma clang loop interleave(disable)
13 // CHECK: #pragma clang loop vectorize(enable)
14 // CHECK: #pragma clang loop distribute(disable)
15 // CHECK: #pragma clang loop unroll(full)
16 // CHECK: #pragma clang loop interleave(enable)
17 // CHECK: #pragma clang loop vectorize(disable)
18 // CHECK: #pragma unroll
19 // CHECK: #pragma unroll (32)
20 // CHECK: #pragma nounroll
21 // CHECK: #pragma clang loop interleave_count(I)
22 // CHECK: #pragma clang loop vectorize_width(V)
23 
24 #ifndef HEADER
25 #define HEADER
26 
27 class pragma_test {
28 public:
run1(int * List,int Length)29   inline void run1(int *List, int Length) {
30     int i = 0;
31 #pragma clang loop vectorize_width(4)
32 #pragma clang loop interleave_count(8)
33 #pragma clang loop unroll_count(16)
34     while (i < Length) {
35       List[i] = i;
36       i++;
37     }
38   }
39 
run2(int * List,int Length)40   inline void run2(int *List, int Length) {
41     int i = 0;
42 #pragma clang loop vectorize(enable)
43 #pragma clang loop interleave(disable)
44 #pragma clang loop unroll(disable)
45 #pragma clang loop distribute(enable)
46     while (i - 1 < Length) {
47       List[i] = i;
48       i++;
49     }
50   }
51 
run3(int * List,int Length)52   inline void run3(int *List, int Length) {
53     int i = 0;
54 #pragma clang loop vectorize(disable)
55 #pragma clang loop interleave(enable)
56 #pragma clang loop unroll(full)
57 #pragma clang loop distribute(disable)
58     while (i - 3 < Length) {
59       List[i] = i;
60       i++;
61     }
62   }
63 
run4(int * List,int Length)64   inline void run4(int *List, int Length) {
65     int i = 0;
66 #pragma unroll
67     while (i - 3 < Length) {
68       List[i] = i;
69       i++;
70     }
71   }
72 
run5(int * List,int Length)73   inline void run5(int *List, int Length) {
74     int i = 0;
75 #pragma unroll 32
76     while (i - 3 < Length) {
77       List[i] = i;
78       i++;
79     }
80   }
81 
run6(int * List,int Length)82   inline void run6(int *List, int Length) {
83     int i = 0;
84 #pragma nounroll
85     while (i - 3 < Length) {
86       List[i] = i;
87       i++;
88     }
89   }
90 
91   template <int V, int I>
run7(int * List,int Length)92   inline void run7(int *List, int Length) {
93 #pragma clang loop vectorize_width(V)
94 #pragma clang loop interleave_count(I)
95     for (int i = 0; i < Length; i++) {
96       List[i] = i;
97     }
98   }
99 };
100 #else
101 
test()102 void test() {
103   int List[100];
104 
105   pragma_test pt;
106 
107   pt.run1(List, 100);
108   pt.run2(List, 100);
109   pt.run3(List, 100);
110   pt.run4(List, 100);
111   pt.run5(List, 100);
112   pt.run6(List, 100);
113   pt.run7<2, 4>(List, 100);
114 }
115 
116 #endif
117