blob: a86762e02b548b176dc519e7a6ac697c863bd9e0 [file] [log] [blame]
Anastasia Stulova6bdbcbb2016-02-19 18:30:11 +00001// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
2
3/*** for ***/
4void for_count()
5{
6// CHECK-LABEL: for_count
7 __attribute__((opencl_unroll_hint(8)))
8 for( int i = 0; i < 1000; ++i);
9// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]]
10}
11
12void for_disable()
13{
14// CHECK-LABEL: for_disable
15 __attribute__((opencl_unroll_hint(1)))
16 for( int i = 0; i < 1000; ++i);
17// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]
18}
19
20void for_full()
21{
22// CHECK-LABEL: for_full
23 __attribute__((opencl_unroll_hint))
24 for( int i = 0; i < 1000; ++i);
25// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]]
26}
27
28/*** while ***/
29void while_count()
30{
31// CHECK-LABEL: while_count
32 int i = 1000;
33 __attribute__((opencl_unroll_hint(8)))
34 while(i-->0);
35// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]]
36}
37
38void while_disable()
39{
40// CHECK-LABEL: while_disable
41 int i = 1000;
42 __attribute__((opencl_unroll_hint(1)))
43 while(i-->0);
44// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]
45}
46
47void while_full()
48{
49// CHECK-LABEL: while_full
50 int i = 1000;
51 __attribute__((opencl_unroll_hint))
52 while(i-->0);
53// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]]
54}
55
56/*** do ***/
57void do_count()
58{
59// CHECK-LABEL: do_count
60 int i = 1000;
61 __attribute__((opencl_unroll_hint(8)))
62 do {} while(i--> 0);
63// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]]
64}
65
66void do_disable()
67{
68// CHECK-LABEL: do_disable
69 int i = 1000;
70 __attribute__((opencl_unroll_hint(1)))
71 do {} while(i--> 0);
72// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]
73}
74
75void do_full()
76{
77// CHECK-LABEL: do_full
78 int i = 1000;
79 __attribute__((opencl_unroll_hint))
80 do {} while(i--> 0);
81// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]]
82}
83
84
85// CHECK: ![[FOR_COUNT]] = distinct !{![[FOR_COUNT]], ![[COUNT:.*]]}
86// CHECK: ![[COUNT]] = !{!"llvm.loop.unroll.count", i32 8}
87// CHECK: ![[FOR_DISABLE]] = distinct !{![[FOR_DISABLE]], ![[DISABLE:.*]]}
88// CHECK: ![[DISABLE]] = !{!"llvm.loop.unroll.disable"}
89// CHECK: ![[FOR_FULL]] = distinct !{![[FOR_FULL]], ![[FULL:.*]]}
90// CHECK: ![[FULL]] = !{!"llvm.loop.unroll.full"}
91// CHECK: ![[WHILE_COUNT]] = distinct !{![[WHILE_COUNT]], ![[COUNT]]}
92// CHECK: ![[WHILE_DISABLE]] = distinct !{![[WHILE_DISABLE]], ![[DISABLE]]}
93// CHECK: ![[WHILE_FULL]] = distinct !{![[WHILE_FULL]], ![[FULL]]}
94// CHECK: ![[DO_COUNT]] = distinct !{![[DO_COUNT]], ![[COUNT]]}
95// CHECK: ![[DO_DISABLE]] = distinct !{![[DO_DISABLE]], ![[DISABLE]]}
96// CHECK: ![[DO_FULL]] = distinct !{![[DO_FULL]], ![[FULL]]}