Home | History | Annotate | Download | only in PCH
      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 unroll(disable)
     11 // CHECK: #pragma clang loop interleave(disable)
     12 // CHECK: #pragma clang loop vectorize(enable)
     13 // CHECK: #pragma clang loop unroll(full)
     14 // CHECK: #pragma clang loop interleave(enable)
     15 // CHECK: #pragma clang loop vectorize(disable)
     16 // CHECK: #pragma unroll
     17 // CHECK: #pragma unroll (32)
     18 // CHECK: #pragma nounroll
     19 // CHECK: #pragma clang loop interleave_count(I)
     20 // CHECK: #pragma clang loop vectorize_width(V)
     21 
     22 #ifndef HEADER
     23 #define HEADER
     24 
     25 class pragma_test {
     26 public:
     27   inline void run1(int *List, int Length) {
     28     int i = 0;
     29 #pragma clang loop vectorize_width(4)
     30 #pragma clang loop interleave_count(8)
     31 #pragma clang loop unroll_count(16)
     32     while (i < Length) {
     33       List[i] = i;
     34       i++;
     35     }
     36   }
     37 
     38   inline void run2(int *List, int Length) {
     39     int i = 0;
     40 #pragma clang loop vectorize(enable)
     41 #pragma clang loop interleave(disable)
     42 #pragma clang loop unroll(disable)
     43     while (i - 1 < Length) {
     44       List[i] = i;
     45       i++;
     46     }
     47   }
     48 
     49   inline void run3(int *List, int Length) {
     50     int i = 0;
     51 #pragma clang loop vectorize(disable)
     52 #pragma clang loop interleave(enable)
     53 #pragma clang loop unroll(full)
     54     while (i - 3 < Length) {
     55       List[i] = i;
     56       i++;
     57     }
     58   }
     59 
     60   inline void run4(int *List, int Length) {
     61     int i = 0;
     62 #pragma unroll
     63     while (i - 3 < Length) {
     64       List[i] = i;
     65       i++;
     66     }
     67   }
     68 
     69   inline void run5(int *List, int Length) {
     70     int i = 0;
     71 #pragma unroll 32
     72     while (i - 3 < Length) {
     73       List[i] = i;
     74       i++;
     75     }
     76   }
     77 
     78   inline void run6(int *List, int Length) {
     79     int i = 0;
     80 #pragma nounroll
     81     while (i - 3 < Length) {
     82       List[i] = i;
     83       i++;
     84     }
     85   }
     86 
     87   template <int V, int I>
     88   inline void run7(int *List, int Length) {
     89 #pragma clang loop vectorize_width(V)
     90 #pragma clang loop interleave_count(I)
     91     for (int i = 0; i < Length; i++) {
     92       List[i] = i;
     93     }
     94   }
     95 };
     96 #else
     97 
     98 void test() {
     99   int List[100];
    100 
    101   pragma_test pt;
    102 
    103   pt.run1(List, 100);
    104   pt.run2(List, 100);
    105   pt.run3(List, 100);
    106   pt.run4(List, 100);
    107   pt.run5(List, 100);
    108   pt.run6(List, 100);
    109   pt.run7<2, 4>(List, 100);
    110 }
    111 
    112 #endif
    113