From b937207dccd05f700855e9aeb3f7c375b595b827 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 12 Apr 2024 14:40:30 -0700 Subject: Fix IR lowering bug of do-while loops. (#3941) --- tests/bugs/gh-3930.slang | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/bugs/gh-3930.slang (limited to 'tests') 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]); + } + } +} -- cgit v1.2.3