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