137 lines · plain
1// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \2// RUN: dxil-pc-shadermodel6.3-library -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s3 4/*** for ***/5void for_count()6{7// CHECK-LABEL: for_count8 [unroll(8)]9 for( int i = 0; i < 1000; ++i);10// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISTINCT:.*]]11}12 13void for_disable()14{15// CHECK-LABEL: for_disable16 [loop]17 for( int i = 0; i < 1000; ++i);18// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]19}20 21void for_enable()22{23// CHECK-LABEL: for_enable24 [unroll]25 for( int i = 0; i < 1000; ++i);26// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_ENABLE:.*]]27}28 29void for_nested_one_unroll_enable()30{31// CHECK-LABEL: for_nested_one_unroll_enable32 int s = 0;33 [unroll]34 for( int i = 0; i < 1000; ++i) {35 for( int j = 0; j < 10; ++j)36 s += i + j;37 }38// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_NESTED_ENABLE_INNER:.*]]39// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_NESTED_ENABLE_OUTER:.*]]40}41 42void for_nested_two_unroll_enable()43{44// CHECK-LABEL: for_nested_two_unroll_enable45 int s = 0;46 [unroll]47 for( int i = 0; i < 1000; ++i) {48 [unroll]49 for( int j = 0; j < 10; ++j)50 s += i + j;51 }52// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_NESTED2_ENABLE:.*]]53// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_NESTED2_1_ENABLE:.*]]54}55 56 57/*** while ***/58void while_count()59{60// CHECK-LABEL: while_count61 int i = 1000;62 [unroll(4)]63 while(i-->0);64// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISTINCT:.*]]65}66 67void while_disable()68{69// CHECK-LABEL: while_disable70 int i = 1000;71 [loop]72 while(i-->0);73// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]74}75 76void while_enable()77{78// CHECK-LABEL: while_enable79 int i = 1000;80 [unroll]81 while(i-->0);82// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_ENABLE:.*]]83}84 85/*** do ***/86void do_count()87{88// CHECK-LABEL: do_count89 int i = 1000;90 [unroll(16)]91 do {} while(i--> 0);92// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISTINCT:.*]]93}94 95void do_disable()96{97// CHECK-LABEL: do_disable98 int i = 1000;99 [loop]100 do {} while(i--> 0);101// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]102}103 104void do_enable()105{106// CHECK-LABEL: do_enable107 int i = 1000;108 [unroll]109 do {} while(i--> 0);110// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_ENABLE:.*]]111}112 113 114// CHECK-DAG: [[MUST_PROGRESS:.*]] = !{!"llvm.loop.mustprogress"}115// CHECK-DAG: [[DISABLE:.*]] = !{!"llvm.loop.unroll.disable"}116// CHECK-DAG: [[FOR_COUNT:.*]] = !{!"llvm.loop.unroll.count", i32 8}117// CHECK-DAG: [[ENABLE:.*]] = !{!"llvm.loop.unroll.enable"}118// CHECK-DAG: [[WHILE_COUNT:.*]] = !{!"llvm.loop.unroll.count", i32 4}119// CHECK-DAG: [[DO_COUNT:.*]] = !{!"llvm.loop.unroll.count", i32 16}120 121// CHECK-DAG: ![[FOR_DISTINCT]] = distinct !{![[FOR_DISTINCT]], [[MUST_PROGRESS]], [[FOR_COUNT]]}122// CHECK-DAG: ![[FOR_DISABLE]] = distinct !{![[FOR_DISABLE]], [[MUST_PROGRESS]], [[DISABLE]]}123// CHECK-DAG: ![[FOR_ENABLE]] = distinct !{![[FOR_ENABLE]], [[MUST_PROGRESS]], [[ENABLE]]}124 125// CHECK-DAG: ![[FOR_NESTED_ENABLE_INNER]] = distinct !{![[FOR_NESTED_ENABLE_INNER]], [[MUST_PROGRESS]]}126// CHECK-DAG: ![[FOR_NESTED_ENABLE_OUTER]] = distinct !{![[FOR_NESTED_ENABLE_OUTER]], [[MUST_PROGRESS]], [[ENABLE]]}127// CHECK-DAG: ![[FOR_NESTED2_ENABLE]] = distinct !{![[FOR_NESTED2_ENABLE]], [[MUST_PROGRESS]], [[ENABLE]]}128// CHECK-DAG: ![[FOR_NESTED2_1_ENABLE]] = distinct !{![[FOR_NESTED2_1_ENABLE]], [[MUST_PROGRESS]], [[ENABLE]]}129// CHECK-DAG: ![[WHILE_DISTINCT]] = distinct !{![[WHILE_DISTINCT]], [[MUST_PROGRESS]], [[WHILE_COUNT]]}130 131// CHECK-DAG: ![[WHILE_DISABLE]] = distinct !{![[WHILE_DISABLE]], [[MUST_PROGRESS]], [[DISABLE]]}132// CHECK-DAG: ![[WHILE_ENABLE]] = distinct !{![[WHILE_ENABLE]], [[MUST_PROGRESS]], [[ENABLE]]}133// CHECK-DAG: ![[DO_DISTINCT]] = distinct !{![[DO_DISTINCT]], [[MUST_PROGRESS]], [[DO_COUNT]]}134 135// CHECK-DAG: ![[DO_DISABLE]] = distinct !{![[DO_DISABLE]], [[MUST_PROGRESS]], [[DISABLE]]}136// CHECK-DAG: ![[DO_ENABLE]] = distinct !{![[DO_ENABLE]], [[MUST_PROGRESS]], [[ENABLE]]}137