summaryrefslogtreecommitdiff
path: root/tests/bugs/inversion-tricky-phi.slang
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-11-07 05:21:49 +0800
committerGitHub <noreply@github.com>2023-11-06 13:21:49 -0800
commitda9e0adb5cf2b1bed6075a3afe93cfdcceabe904 (patch)
tree7ac721efa3821c1d304a20f0ea3a2ee1e3482f23 /tests/bugs/inversion-tricky-phi.slang
parent79677b83870577fbad9ce65a731d3ae8a4c553c1 (diff)
Correctly pass values from the conditional block to the loop during inversion (#3311)
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/bugs/inversion-tricky-phi.slang')
-rw-r--r--tests/bugs/inversion-tricky-phi.slang32
1 files changed, 32 insertions, 0 deletions
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<float> 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);
+}