summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-06-02 10:27:13 +0800
committerGitHub <noreply@github.com>2024-06-01 19:27:13 -0700
commit0bc89bc13251fedc9ed90cf473d2e6eb7fda3abf (patch)
tree564e5160660c8b65e9f7b9b15c1e7d3c0d863f11 /tests
parentc5a453e56985022deb820cbbb2ff5cd6a8347e34 (diff)
Prevent hoisting of non-hoistable instructions in non-function values with code (#4250)
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/generic-initializer-inlining.slang33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/bugs/generic-initializer-inlining.slang b/tests/bugs/generic-initializer-inlining.slang
new file mode 100644
index 000000000..8f126e43a
--- /dev/null
+++ b/tests/bugs/generic-initializer-inlining.slang
@@ -0,0 +1,33 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu
+
+// CHECK: 1
+// CHECK-NEXT: 0
+// CHECK-NEXT: 0
+// CHECK-NEXT: 0
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+struct C<T>
+{
+ [ForceInline]
+ __init<U>(U value)
+ {
+ for (int i = 0; i < 1; ++i)
+ {}
+ }
+}
+
+static C<int> c = C<int>(1);
+
+int use<T>(T x)
+{
+ return 1;
+}
+
+[numthreads(1, 1, 1)]
+void computeMain(uint i : SV_GroupIndex)
+{
+ outputBuffer[0] = use(c);
+}
+