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       List[i * Length + j] = Value;
10     }
11   }
12 }
13 
unroll_and_jam_count(int * List,int Length,int Value)14 void unroll_and_jam_count(int *List, int Length, int Value) {
15   // CHECK-LABEL: define {{.*}} @_Z20unroll_and_jam_count
16 #pragma unroll_and_jam(4)
17   for (int i = 0; i < Length; i++) {
18     for (int j = 0; j < Length; j++) {
19       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_2:.*]]
20       List[i * Length + j] = Value;
21     }
22   }
23 }
24 
nounroll_and_jam(int * List,int Length,int Value)25 void nounroll_and_jam(int *List, int Length, int Value) {
26   // CHECK-LABEL: define {{.*}} @_Z16nounroll_and_jam
27 #pragma nounroll_and_jam
28   for (int i = 0; i < Length; i++) {
29     for (int j = 0; j < Length; j++) {
30       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_3:.*]]
31       List[i * Length + j] = Value;
32     }
33   }
34 }
35 
clang_unroll_plus_nounroll_and_jam(int * List,int Length,int Value)36 void clang_unroll_plus_nounroll_and_jam(int *List, int Length, int Value) {
37   // CHECK-LABEL: define {{.*}} @_Z34clang_unroll_plus_nounroll_and_jam
38 #pragma nounroll_and_jam
39 #pragma unroll(4)
40   for (int i = 0; i < Length; i++) {
41     for (int j = 0; j < Length; j++) {
42       // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_7:.*]]
43       List[i * Length + j] = Value;
44     }
45   }
46 }
47 
48 // CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNJ_ENABLE:.*]]}
49 // CHECK: ![[UNJ_ENABLE]] = !{!"llvm.loop.unroll_and_jam.enable"}
50 // CHECK: ![[LOOP_2]] = distinct !{![[LOOP_2]], ![[UNJ_4:.*]]}
51 // CHECK: ![[UNJ_4]] = !{!"llvm.loop.unroll_and_jam.count", i32 4}
52 // CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], ![[UNJ_DISABLE:.*]]}
53 // CHECK: ![[UNJ_DISABLE]] = !{!"llvm.loop.unroll_and_jam.disable"}
54 // CHECK: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[UNJ_DISABLE:.*]], ![[UNROLL_4:.*]]}
55 // CHECK: ![[UNROLL_4]] = !{!"llvm.loop.unroll.count", i32 4}
56