1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
3 void loop1(int *List
, int Length
) {
4 // CHECK-LABEL: @{{.*}}loop1{{.*}}(
5 // CHECK: br label {{.*}}, !llvm.loop ![[LOOP1:.*]]
7 #pragma clang loop vectorize(enable) vectorize_width(1)
8 for (int i
= 0; i
< Length
; i
++)
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:.*]]
18 #pragma clang loop vectorize(enable) vectorize_width(2)
19 for (int i
= 0; i
< Length
; i
++)
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:.*]]
28 #pragma clang loop vectorize_width(1)
29 for (int i
= 0; i
< Length
; i
++)
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:.*]]
38 #pragma clang loop vectorize_width(2)
39 for (int i
= 0; i
< Length
; i
++)
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}
48 // CHECK: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], ![[VEC_WIDTH_2:.*]], ![[FIXED_WIDTH:.*]], ![[VEC_ENABLE]]}
49 // CHECK: ![[VEC_WIDTH_2]] = !{!"llvm.loop.vectorize.width", i32 2}
51 // CHECK: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], ![[VEC_WIDTH_1]], ![[FIXED_WIDTH]]}
53 // CHECK: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], ![[VEC_WIDTH_2]], ![[FIXED_WIDTH]], ![[VEC_ENABLE]]}