diff options
| author | Yong He <yonghe@outlook.com> | 2024-04-12 14:40:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-12 14:40:30 -0700 |
| commit | b937207dccd05f700855e9aeb3f7c375b595b827 (patch) | |
| tree | 19146073437f9f02c7784f974519cce02ca7a6db /tests | |
| parent | 565a871ad899c01dc6a1b4bdb1b9d2bc4281758f (diff) | |
Fix IR lowering bug of do-while loops. (#3941)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-3930.slang | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/bugs/gh-3930.slang b/tests/bugs/gh-3930.slang new file mode 100644 index 000000000..6ba860ef3 --- /dev/null +++ b/tests/bugs/gh-3930.slang @@ -0,0 +1,26 @@ +// A regression: the do-while loop ir lowering logic is making incorrect assumptions and is +// broken after short circuiting expr change, leading to invalid IR being generated from lowering +// (a block has two terminator insts). + +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly + +// CHECK: OpEntryPoint + +struct Constants { + uint *buffer; +} +[[vk::push_constant]] Constants push_constants; + +[shader("compute")] [numthreads(1, 1, 1)] void compute(void) { + uint index = push_constants.buffer[0]; + + [[unroll]] for (uint i = 0; i < 2; i++) { + GroupMemoryBarrierWithWaveSync(); + + if (index > 0 && i < push_constants.buffer[index - 1]) { + do { + index--; + } while (index > 0 && i < push_constants.buffer[index - 1]); + } + } +} |
