summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-01 14:32:30 -0700
committerGitHub <noreply@github.com>2024-04-01 14:32:30 -0700
commit65ac9f3a9ddcb8bcfc099ffb29beaa9a92ba1f53 (patch)
tree58b20c58d71dca4d807db7830d61b0d8c96cf8d7 /tests
parent844a8d6274cb5e4927bf3241a94b2a9d9553df90 (diff)
Fix peephole optimization of `TypeEquals`. (#3865)
Closes #3861.
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/types/is-on-type.slang45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/language-feature/types/is-on-type.slang b/tests/language-feature/types/is-on-type.slang
new file mode 100644
index 000000000..e9dd48fcf
--- /dev/null
+++ b/tests/language-feature/types/is-on-type.slang
@@ -0,0 +1,45 @@
+
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute
+
+// Test that `is` operator works on generic type param.
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+interface I
+{
+
+}
+
+struct A : I
+{
+ uint i;
+};
+
+struct B : I
+{
+ float2 f2;
+};
+
+func test<T : I>(T t) -> int
+{
+ int rs = 0;
+ if (T is A)
+ {
+ rs++;
+ }
+ if (T is B)
+ {
+ rs+=2;
+ }
+ return rs;
+}
+
+[shader("compute")]
+[numthreads(1,1, 1)]
+void computeMain()
+{
+ B b;
+ // CHECK: 2
+ outputBuffer[0] = test(b);
+} \ No newline at end of file