diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2025-07-28 15:29:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-28 19:29:58 +0000 |
| commit | 5f8475bee2589b8e851c856135cf10758e859e72 (patch) | |
| tree | 98517a1b532144cbab9000b40a3424321615d7c1 /tests/bugs | |
| parent | 4ca545ed9e98fa49740b3537473e02b950c23a99 (diff) | |
Fix issue in multi-level break elimination by handling multi-level continue statements (#7953)
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/gh-7748-switch-continue-bug.slang | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/bugs/gh-7748-switch-continue-bug.slang b/tests/bugs/gh-7748-switch-continue-bug.slang new file mode 100644 index 000000000..4feca7180 --- /dev/null +++ b/tests/bugs/gh-7748-switch-continue-bug.slang @@ -0,0 +1,45 @@ +//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-output-using-type -cpu + +// Regression test for issue #7748: Dictionary key collision in multi-level break processing +// This test specifically exercises the case of "continue inside a switch that is inside a for loop" +// which was identified as the root cause of the dictionary collision issue. + +int testContinueInSwitchInLoop(int value) { + int result = 0; + + for (int i = 0; i < 3; ++i) { + switch (value) { + case 0: + result += 1; + continue; // This continue should go to the for loop + case 1: + result += 2; + break; // This break goes to the switch + default: + result += 3; + break; + } + result += 10; // This should be skipped when continue is used + } + + return result; +} + +int processValues() { + int sum = 0; + sum += testContinueInSwitchInLoop(0); // Should be 3 (1+1+1, no +10s due to continue) + sum += testContinueInSwitchInLoop(1); // Should be 36 (2+10, 2+10, 2+10) + sum += testContinueInSwitchInLoop(2); // Should be 39 (3+10, 3+10, 3+10) + return sum; +} + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() { + int result = processValues(); + outputBuffer[0] = result; + //CHECK: 78 +}
\ No newline at end of file |
