aboutsummaryrefslogtreecommitdiff
path: root/test/PCH/pragma-loop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/PCH/pragma-loop.cpp')
-rw-r--r--test/PCH/pragma-loop.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/test/PCH/pragma-loop.cpp b/test/PCH/pragma-loop.cpp
new file mode 100644
index 000000000000..1456a2778f33
--- /dev/null
+++ b/test/PCH/pragma-loop.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -emit-pch -o %t.a %s
+// RUN: %clang_cc1 -include-pch %t.a %s -ast-print -o - | FileCheck %s
+
+// FIXME: A bug in ParsedAttributes causes the order of the attributes to be
+// reversed. The checks are consequently in the reverse order below.
+
+// CHECK: #pragma clang loop unroll_count(16)
+// CHECK: #pragma clang loop interleave_count(8)
+// CHECK: #pragma clang loop vectorize_width(4)
+// CHECK: #pragma clang loop unroll(disable)
+// CHECK: #pragma clang loop interleave(disable)
+// CHECK: #pragma clang loop vectorize(enable)
+// CHECK: #pragma clang loop unroll(enable)
+// CHECK: #pragma clang loop interleave(enable)
+// CHECK: #pragma clang loop vectorize(disable)
+// CHECK: #pragma unroll
+// CHECK: #pragma unroll (32)
+
+#ifndef HEADER
+#define HEADER
+
+class pragma_test {
+public:
+ inline void run1(int *List, int Length) {
+ int i = 0;
+#pragma clang loop vectorize_width(4)
+#pragma clang loop interleave_count(8)
+#pragma clang loop unroll_count(16)
+ while (i < Length) {
+ List[i] = i;
+ i++;
+ }
+ }
+
+ inline void run2(int *List, int Length) {
+ int i = 0;
+#pragma clang loop vectorize(enable)
+#pragma clang loop interleave(disable)
+#pragma clang loop unroll(disable)
+ while (i - 1 < Length) {
+ List[i] = i;
+ i++;
+ }
+ }
+
+ inline void run3(int *List, int Length) {
+ int i = 0;
+#pragma clang loop vectorize(disable)
+#pragma clang loop interleave(enable)
+#pragma clang loop unroll(enable)
+ while (i - 3 < Length) {
+ List[i] = i;
+ i++;
+ }
+ }
+
+ inline void run4(int *List, int Length) {
+ int i = 0;
+#pragma unroll
+ while (i - 3 < Length) {
+ List[i] = i;
+ i++;
+ }
+ }
+
+ inline void run5(int *List, int Length) {
+ int i = 0;
+#pragma unroll 32
+ while (i - 3 < Length) {
+ List[i] = i;
+ i++;
+ }
+ }
+};
+
+#else
+
+void test() {
+ int List[100];
+
+ pragma_test pt;
+
+ pt.run1(List, 100);
+ pt.run2(List, 100);
+ pt.run3(List, 100);
+ pt.run4(List, 100);
+ pt.run5(List, 100);
+}
+
+#endif