diff options
Diffstat (limited to 'tests/ir')
| -rw-r--r-- | tests/ir/loop-dce.slang | 40 | ||||
| -rw-r--r-- | tests/ir/loop-dce.slang.expected.txt | 4 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/ir/loop-dce.slang b/tests/ir/loop-dce.slang new file mode 100644 index 000000000..f89c1aa38 --- /dev/null +++ b/tests/ir/loop-dce.slang @@ -0,0 +1,40 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +__target_intrinsic(hlsl, "@") +__target_intrinsic(glsl, "@") +__target_intrinsic(cpp, "@") +__target_intrinsic(cuda, "@") +[__readNone] +int produceSyntaxError() { return 0; } + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) +{ + int sum = 0; + int array[100]; + // Next, this loop will be removed because there is no use of `array`. + for (int i = 0; i < 100; i++) + { + // This loop must be removed, or we will fail downstream compilation. + array[i] = i + produceSyntaxError(); + } + + // First, this loop will be removed because there is no use of `sum`. + for (int i = 0; i < 100; i++) + { + // This loop must be removed, or we will fail downstream compilation. + if (i < 50) + { + sum += array[i] + produceSyntaxError(); + } + else + { + sum += i * 2 + produceSyntaxError(); + } + } + outputBuffer[0] = 1; +} diff --git a/tests/ir/loop-dce.slang.expected.txt b/tests/ir/loop-dce.slang.expected.txt new file mode 100644 index 000000000..968ac3ef0 --- /dev/null +++ b/tests/ir/loop-dce.slang.expected.txt @@ -0,0 +1,4 @@ +1 +0 +0 +0 |
