1 // RUN: %clang_cc1 -triple arm-none-eabi -std=c++11 -emit-llvm -o - %s | FileCheck %s
2 
unroll_and_jam(int * List,int Length,int Value)3 void unroll_and_jam(int *List, int Length, int Value) {
4   // CHECK-LABEL: define {{.*}} @_Z14unroll_and_jam
5 #pragma unroll_and_jam
6   for (int i = 0; i < Length; i++) {
7     for (int j = 0; j < Length; j++) {
8       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_1:.*]]
9       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_2:.*]]
10       List[i * Length + j] = Value;
11     }
12   }
13 }
14 
unroll_and_jam_count(int * List,int Length,int Value)15 void unroll_and_jam_count(int *List, int Length, int Value) {
16   // CHECK-LABEL: define {{.*}} @_Z20unroll_and_jam_count
17 #pragma unroll_and_jam(4)
18   for (int i = 0; i < Length; i++) {
19     for (int j = 0; j < Length; j++) {
20       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_3:.*]]
21       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_4:.*]]
22       List[i * Length + j] = Value;
23     }
24   }
25 }
26 
nounroll_and_jam(int * List,int Length,int Value)27 void nounroll_and_jam(int *List, int Length, int Value) {
28   // CHECK-LABEL: define {{.*}} @_Z16nounroll_and_jam
29 #pragma nounroll_and_jam
30   for (int i = 0; i < Length; i++) {
31     for (int j = 0; j < Length; j++) {
32       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_5:.*]]
33       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_6:.*]]
34       List[i * Length + j] = Value;
35     }
36   }
37 }
38 
clang_unroll_plus_nounroll_and_jam(int * List,int Length,int Value)39 void clang_unroll_plus_nounroll_and_jam(int *List, int Length, int Value) {
40   // CHECK-LABEL: define {{.*}} @_Z34clang_unroll_plus_nounroll_and_jam
41 #pragma nounroll_and_jam
42 #pragma unroll(4)
43   for (int i = 0; i < Length; i++) {
44     for (int j = 0; j < Length; j++) {
45       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_7:.*]]
46       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_8:.*]]
47       List[i * Length + j] = Value;
48     }
49   }
50 }
51 
52 // CHECK: ![[LOOP_2]] = distinct !{![[LOOP_2]], [[MP:![0-9]+]], ![[UNJ_ENABLE:.*]]}
53 // CHECK: ![[UNJ_ENABLE]] = !{!"llvm.loop.unroll_and_jam.enable"}
54 // CHECK: ![[LOOP_4]] = distinct !{![[LOOP_4]], [[MP]], ![[UNJ_4:.*]]}
55 // CHECK: ![[UNJ_4]] = !{!"llvm.loop.unroll_and_jam.count", i32 4}
56 // CHECK: ![[LOOP_6]] = distinct !{![[LOOP_6]], [[MP]], ![[UNJ_DISABLE:.*]]}
57 // CHECK: ![[UNJ_DISABLE]] = !{!"llvm.loop.unroll_and_jam.disable"}
58 // CHECK: ![[LOOP_8]] = distinct !{![[LOOP_8]], [[MP]], ![[UNJ_DISABLE:.*]], ![[UNROLL_4:.*]]}
59 // CHECK: ![[UNROLL_4]] = !{!"llvm.loop.unroll.count", i32 4}
60