| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s |
| 2 |
|
| 3 |
void loop1(int *List, int Length) { |
| 4 |
// CHECK-LABEL: @{{.*}}loop1{{.*}}( |
| 5 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP1:.*]] |
| 6 |
|
| 7 |
#pragma clang loop vectorize(enable) vectorize_width(1) |
| 8 |
for (int i = 0; i < Length; i++) |
| 9 |
List[i] = i * 2; |
| 10 |
} |
| 11 |
|
| 12 |
// Here, vectorize.enable should be set, obviously, but also check that |
| 13 |
// metadata isn't added twice. |
| 14 |
void loop2(int *List, int Length) { |
| 15 |
// CHECK-LABEL: @{{.*}}loop2{{.*}}( |
| 16 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP2:.*]] |
| 17 |
|
| 18 |
#pragma clang loop vectorize(enable) vectorize_width(2) |
| 19 |
for (int i = 0; i < Length; i++) |
| 20 |
List[i] = i * 2; |
| 21 |
} |
| 22 |
|
| 23 |
// Test that we do *not* imply vectorize.enable. |
| 24 |
void loop3(int *List, int Length) { |
| 25 |
// CHECK-LABEL: @{{.*}}loop3{{.*}}( |
| 26 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP3:.*]] |
| 27 |
|
| 28 |
#pragma clang loop vectorize_width(1) |
| 29 |
for (int i = 0; i < Length; i++) |
| 30 |
List[i] = i * 2; |
| 31 |
} |
| 32 |
|
| 33 |
// Test that we *do* imply vectorize.enable. |
| 34 |
void loop4(int *List, int Length) { |
| 35 |
// CHECK-LABEL: @{{.*}}loop4{{.*}}( |
| 36 |
// CHECK: br label {{.*}}, !llvm.loop ![[LOOP4:.*]] |
| 37 |
|
| 38 |
#pragma clang loop vectorize_width(2) |
| 39 |
for (int i = 0; i < Length; i++) |
| 40 |
List[i] = i * 2; |
| 41 |
} |
| 42 |
|
| 43 |
// CHECK: ![[LOOP1]] = distinct !{![[LOOP1]], [[MP:![0-9]+]], ![[VEC_WIDTH_1:.*]], ![[FIXED_WIDTH:.*]], ![[VEC_ENABLE:.*]]} |
| 44 |
// CHECK: ![[VEC_WIDTH_1]] = !{!"llvm.loop.vectorize.width", i32 1} |
| 45 |
// CHECK: ![[FIXED_WIDTH]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} |
| 46 |
// CHECK: ![[VEC_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true} |
| 47 |
|
| 48 |
// CHECK: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], ![[VEC_WIDTH_2:.*]], ![[FIXED_WIDTH:.*]], ![[VEC_ENABLE]]} |
| 49 |
// CHECK: ![[VEC_WIDTH_2]] = !{!"llvm.loop.vectorize.width", i32 2} |
| 50 |
|
| 51 |
// CHECK: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], ![[VEC_WIDTH_1]], ![[FIXED_WIDTH]]} |
| 52 |
|
| 53 |
// CHECK: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], ![[VEC_WIDTH_2]], ![[FIXED_WIDTH]], ![[VEC_ENABLE]]} |