summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-12 13:48:40 -0700
committerGitHub <noreply@github.com>2024-06-12 13:48:40 -0700
commit085d1a603eac69f66b5357276ea07d1978832030 (patch)
tree6137f0fb92e86efbf60b8e0641eb51508338e103 /tests
parent8813c610562b1c30222ec3ef0734ef601d43b617 (diff)
Fix emit logic for getElementPtr. (#4362)
* Fix emit logic for getElementPtr. * Legalize `getElementPtr(vector, id)` for metal. * Fix compiler error. * Fix warnings. * Fix test. * Fix.
Diffstat (limited to 'tests')
-rw-r--r--tests/metal/vector-get-element-ptr.slang24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/metal/vector-get-element-ptr.slang b/tests/metal/vector-get-element-ptr.slang
new file mode 100644
index 000000000..af2acabbc
--- /dev/null
+++ b/tests/metal/vector-get-element-ptr.slang
@@ -0,0 +1,24 @@
+//TEST:SIMPLE(filecheck=CHECK): -target metal
+
+//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -mtl
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+void modify(inout int v)
+{
+ v = 2;
+}
+
+[numthreads(1,1,1)]
+void computeMain(int3 v : SV_DispatchThreadID)
+{
+ int3 u = v;
+ // CHECK: int [[TEMP:[a-zA-Z0-9_]+]] = u{{.*}}.x;
+ // CHECK: modify{{.*}}(&[[TEMP]])
+ // CHECK: u{{.*}}.x = [[TEMP]];
+
+ modify(u.x);
+ // BUF: 2
+ outputBuffer[0] = u.x + u.y;
+} \ No newline at end of file