diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-24 10:01:47 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-24 10:01:47 -0800 |
| commit | bd6306cdaa4a49344658bd026721b6532e103d09 (patch) | |
| tree | bb7f666d426e6cfc7777a3ccac0a1d628588eb39 /tests/ir | |
| parent | e8c08e7ecb1124f115a1d1042277776193122b57 (diff) | |
More control flow simplifications. (#2673)
* More control flow and Phi param simplifications.
* Fix.
* Fix gcc error.
* Fix.
* More IR cleanup.
* Fix bug in phi param dce + ifelse simplify.
* Propagate and DCE side-effect-free functions.
* Enhance CFG simplifcation to remove loops with no side effects.
* Fix.
* Fixes.
* Fix tests. Add [__AlwaysFoldIntoUseSite] for rayPayloadLocation.
* More cleanup.
* Fixes.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
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 |
