From da9e0adb5cf2b1bed6075a3afe93cfdcceabe904 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 7 Nov 2023 05:21:49 +0800 Subject: Correctly pass values from the conditional block to the loop during inversion (#3311) Co-authored-by: Yong He --- tests/bugs/inversion-tricky-phi.slang | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/bugs/inversion-tricky-phi.slang (limited to 'tests') diff --git a/tests/bugs/inversion-tricky-phi.slang b/tests/bugs/inversion-tricky-phi.slang new file mode 100644 index 000000000..c0a6417f2 --- /dev/null +++ b/tests/bugs/inversion-tricky-phi.slang @@ -0,0 +1,32 @@ +//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target hlsl + +// Annoyingly, the reproducer for this doesn't terminate, so just check that we +// succeeded compilation. +// Previously, this would fail in SCCP after loop inversion failed to account +// for condition variables being used in the loop. +// CHECK: computeMain + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(uint i : SV_GroupIndex) +{ + float x = 0; + f(x); + outputBuffer[i] = x; +} + +void f(inout float r) +{ + r = 0; + float a = 0; + do { + do { + a = a + 1; + if (a > 0) + break; + } while (true); + r = a; + } while (true); +} -- cgit v1.2.3