diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-04-23 10:37:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-23 10:37:24 -0700 |
| commit | 627de1ce502ce23dc0ef21a69c910a20547aa5c7 (patch) | |
| tree | 1a3ebf5c7d59808f7490bda6df07f593aa194f2c /tests | |
| parent | 163d3068e332703cc499446fff37230a7c68e8f2 (diff) | |
Fix successor computation for `switch` instruction (#520)
Fixes #519
The code was leaving out the `default` label from the successor list,
which would break any passes that require an accurate CFG (with the big
one right now being the SSA-formation pass).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-519.slang | 42 | ||||
| -rw-r--r-- | tests/bugs/gh-519.slang.expected.txt | 4 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/bugs/gh-519.slang b/tests/bugs/gh-519.slang new file mode 100644 index 000000000..35bf6dcd7 --- /dev/null +++ b/tests/bugs/gh-519.slang @@ -0,0 +1,42 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute + +// This bug involved incorrect computation of the successor +// blocks for a `switch`, which led to incorrect SSA form. + +int test(int val) +{ + int tmp = 0; + switch(val) + { + case 0: + tmp = 1; + break; + + case 1: + tmp = 2; + break; + + case 2: + tmp = 3; + break; + + default: + tmp = val + 1; + break; + } + return tmp; +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +RWStructuredBuffer<int> gBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int val = int(tid); + val = test(val); + gBuffer[tid] = val; +}
\ No newline at end of file diff --git a/tests/bugs/gh-519.slang.expected.txt b/tests/bugs/gh-519.slang.expected.txt new file mode 100644 index 000000000..94ebaf900 --- /dev/null +++ b/tests/bugs/gh-519.slang.expected.txt @@ -0,0 +1,4 @@ +1 +2 +3 +4 |
