1 // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s 2 3 /*** for ***/ 4 void 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 12 void 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 20 void 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 ***/ 29 void 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 38 void 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 47 void 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 ***/ 57 void 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 66 void 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 75 void 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]]} 97