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