| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s |
| 2 |
|
| 3 |
void test0(int *List, int Length) { |
| 4 |
// CHECK-LABEL: @{{.*}}test0{{.*}}( |
| 5 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP0:.*]] |
| 6 |
|
| 7 |
#pragma clang loop vectorize(enable) |
| 8 |
for (int i = 0; i < Length; i++) |
| 9 |
List[i] = i * 2; |
| 10 |
} |
| 11 |
|
| 12 |
void test1(int *List, int Length) { |
| 13 |
// CHECK-LABEL: @{{.*}}test1{{.*}}( |
| 14 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP1:.*]] |
| 15 |
|
| 16 |
#pragma clang loop vectorize(enable) vectorize_predicate(enable) |
| 17 |
for (int i = 0; i < Length; i++) |
| 18 |
List[i] = i * 2; |
| 19 |
} |
| 20 |
|
| 21 |
void test2(int *List, int Length) { |
| 22 |
// CHECK-LABEL: @{{.*}}test2{{.*}}( |
| 23 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP2:.*]] |
| 24 |
|
| 25 |
#pragma clang loop vectorize(enable) vectorize_predicate(disable) |
| 26 |
for (int i = 0; i < Length; i++) |
| 27 |
List[i] = i * 2; |
| 28 |
} |
| 29 |
|
| 30 |
// vectorize_predicate(enable) implies vectorize(enable) |
| 31 |
void test3(int *List, int Length) { |
| 32 |
// CHECK-LABEL: @{{.*}}test3{{.*}}( |
| 33 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP3:.*]] |
| 34 |
|
| 35 |
#pragma clang loop vectorize_predicate(enable) |
| 36 |
for (int i = 0; i < Length; i++) |
| 37 |
List[i] = i * 2; |
| 38 |
} |
| 39 |
|
| 40 |
// Check that disabling vectorization means a vectorization width of 1, and |
| 41 |
// also that vectorization_predicate isn't enabled. |
| 42 |
void test4(int *List, int Length) { |
| 43 |
// CHECK-LABEL: @{{.*}}test4{{.*}}( |
| 44 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP4:.*]] |
| 45 |
|
| 46 |
#pragma clang loop vectorize(disable) |
| 47 |
for (int i = 0; i < Length; i++) |
| 48 |
List[i] = i * 2; |
| 49 |
} |
| 50 |
|
| 51 |
// Check that vectorize and vectorize_predicate are disabled. |
| 52 |
void test5(int *List, int Length) { |
| 53 |
// CHECK-LABEL: @{{.*}}test5{{.*}}( |
| 54 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP5:.*]] |
| 55 |
|
| 56 |
#pragma clang loop vectorize(disable) vectorize_predicate(enable) |
| 57 |
for (int i = 0; i < Length; i++) |
| 58 |
List[i] = i * 2; |
| 59 |
} |
| 60 |
|
| 61 |
// Check that vectorize_predicate is ignored when vectorization width is 1 |
| 62 |
void test6(int *List, int Length) { |
| 63 |
// CHECK-LABEL: @{{.*}}test6{{.*}}( |
| 64 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]] |
| 65 |
|
| 66 |
#pragma clang loop vectorize_predicate(disable) vectorize_width(1) |
| 67 |
for (int i = 0; i < Length; i++) |
| 68 |
List[i] = i * 2; |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
// Check that vectorize_width(!=1) does not affect vectorize_predicate. |
| 73 |
void test7(int *List, int Length) { |
| 74 |
// CHECK-LABEL: @{{.*}}test7{{.*}}( |
| 75 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]] |
| 76 |
|
| 77 |
#pragma clang loop vectorize_predicate(disable) vectorize_width(4) |
| 78 |
for (int i = 0; i < Length; i++) |
| 79 |
List[i] = i * 2; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
// Check that vectorize_predicate is ignored when vectorization width is 1 |
| 84 |
void test8(int *List, int Length) { |
| 85 |
// CHECK-LABEL: @{{.*}}test8{{.*}}( |
| 86 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP8:.*]] |
| 87 |
|
| 88 |
#pragma clang loop vectorize_predicate(enable) vectorize_width(1) |
| 89 |
for (int i = 0; i < Length; i++) |
| 90 |
List[i] = i * 2; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
// Check that vectorize_width(!=1) does not affect vectorize_predicate. |
| 95 |
void test9(int *List, int Length) { |
| 96 |
// CHECK-LABEL: @{{.*}}test9{{.*}}( |
| 97 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP9:.*]] |
| 98 |
|
| 99 |
#pragma clang loop vectorize_predicate(enable) vectorize_width(4) |
| 100 |
for (int i = 0; i < Length; i++) |
| 101 |
List[i] = i * 2; |
| 102 |
} |
| 103 |
|
| 104 |
// CHECK: ![[LOOP0]] = distinct !{![[LOOP0]], [[MP:![0-9]+]], [[GEN3:![0-9]+]]} |
| 105 |
// CHECK: [[MP]] = !{!"llvm.loop.mustprogress"} |
| 106 |
// CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable", i1 true} |
| 107 |
|
| 108 |
// CHECK-NEXT: ![[LOOP1]] = distinct !{![[LOOP1]], [[MP]], [[GEN6:![0-9]+]], [[GEN3]]} |
| 109 |
// CHECK-NEXT: [[GEN6]] = !{!"llvm.loop.vectorize.predicate.enable", i1 true} |
| 110 |
|
| 111 |
// CHECK-NEXT: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], [[GEN8:![0-9]+]], [[GEN3]]} |
| 112 |
// CHECK-NEXT: [[GEN8]] = !{!"llvm.loop.vectorize.predicate.enable", i1 false} |
| 113 |
|
| 114 |
// CHECK-NEXT: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], [[GEN6]], [[GEN3]]} |
| 115 |
|
| 116 |
// CHECK-NEXT: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], [[GEN10:![0-9]+]]} |
| 117 |
// CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1} |
| 118 |
|
| 119 |
// CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN6]], [[GEN10]]} |
| 120 |
|
| 121 |
// CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN8]], [[GEN10]], [[GEN11:![0-9]+]]} |
| 122 |
// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} |
| 123 |
|
| 124 |
// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN12:![0-9]+]], [[GEN11]], [[GEN3]]} |
| 125 |
// CHECK-NEXT: [[GEN12]] = !{!"llvm.loop.vectorize.width", i32 4} |
| 126 |
|
| 127 |
// CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN6]], [[GEN10]], [[GEN11]]} |
| 128 |
|
| 129 |
// CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], [[GEN12]], [[GEN11]], [[GEN3]]} |