1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
3 void test0(int *List
, int Length
) {
4 // CHECK-LABEL: @{{.*}}test0{{.*}}(
5 // CHECK: br label {{.*}}, !llvm.loop ![[LOOP0:.*]]
7 #pragma clang loop vectorize(enable)
8 for (int i
= 0; i
< Length
; i
++)
12 void test1(int *List
, int Length
) {
13 // CHECK-LABEL: @{{.*}}test1{{.*}}(
14 // CHECK: br label {{.*}}, !llvm.loop ![[LOOP1:.*]]
16 #pragma clang loop vectorize(enable) vectorize_predicate(enable)
17 for (int i
= 0; i
< Length
; i
++)
21 void test2(int *List
, int Length
) {
22 // CHECK-LABEL: @{{.*}}test2{{.*}}(
23 // CHECK: br label {{.*}}, !llvm.loop ![[LOOP2:.*]]
25 #pragma clang loop vectorize(enable) vectorize_predicate(disable)
26 for (int i
= 0; i
< Length
; i
++)
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:.*]]
35 #pragma clang loop vectorize_predicate(enable)
36 for (int i
= 0; i
< Length
; i
++)
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:.*]]
46 #pragma clang loop vectorize(disable)
47 for (int i
= 0; i
< Length
; i
++)
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:.*]]
56 #pragma clang loop vectorize(disable) vectorize_predicate(enable)
57 for (int i
= 0; i
< Length
; i
++)
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:.*]]
66 #pragma clang loop vectorize_predicate(disable) vectorize_width(1)
67 for (int i
= 0; i
< Length
; i
++)
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:.*]]
77 #pragma clang loop vectorize_predicate(disable) vectorize_width(4)
78 for (int i
= 0; i
< Length
; i
++)
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:.*]]
88 #pragma clang loop vectorize_predicate(enable) vectorize_width(1)
89 for (int i
= 0; i
< Length
; i
++)
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:.*]]
99 #pragma clang loop vectorize_predicate(enable) vectorize_width(4)
100 for (int i
= 0; i
< Length
; i
++)
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}
108 // CHECK-NEXT: ![[LOOP1]] = distinct !{![[LOOP1]], [[MP]], [[GEN6:![0-9]+]], [[GEN3]]}
109 // CHECK-NEXT: [[GEN6]] = !{!"llvm.loop.vectorize.predicate.enable", i1 true}
111 // CHECK-NEXT: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], [[GEN8:![0-9]+]], [[GEN3]]}
112 // CHECK-NEXT: [[GEN8]] = !{!"llvm.loop.vectorize.predicate.enable", i1 false}
114 // CHECK-NEXT: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], [[GEN6]], [[GEN3]]}
116 // CHECK-NEXT: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], [[GEN10:![0-9]+]]}
117 // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1}
119 // CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN6]], [[GEN10]]}
121 // CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN8]], [[GEN10]], [[GEN11:![0-9]+]]}
122 // CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false}
124 // CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN12:![0-9]+]], [[GEN11]], [[GEN3]]}
125 // CHECK-NEXT: [[GEN12]] = !{!"llvm.loop.vectorize.width", i32 4}
127 // CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN6]], [[GEN10]], [[GEN11]]}
129 // CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], [[GEN12]], [[GEN11]], [[GEN3]]}