summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGangzheng Tong <tonggangzheng@gmail.com>2025-07-11 13:16:10 -0700
committerGitHub <noreply@github.com>2025-07-11 20:16:10 +0000
commite3afef145e67e74e054407606320be0e42a6aa63 (patch)
tree991d21236c86402fd2b3ae380be46833c6d2938b /tests
parenteaaf0196c052055ff166a870e8f072dd02a6dcce (diff)
Fix metal segfault by check vectorValue before accessing (#7688)
* Check vectorValue before accessing * Fix metal segfault by using IRElementExtract for general vector handling Address review comments by replacing IRMakeVector-specific code with IRElementExtract to handle any vector instruction type (IRIntCast, etc). This makes the code more robust and fixes cases where float2(1,2) creates IRIntCast instead of IRMakeVector. Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * Fix sign comparison warning in metal legalize Cast originalElementCount->getValue() to UInt to avoid comparison between signed and unsigned integers. Co-authored-by: Yong He <csyonghe@users.noreply.github.com> --------- Co-authored-by: Yong He <yonghe@outlook.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Yong He <csyonghe@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/metal/texture-store-vector.slang16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/metal/texture-store-vector.slang b/tests/metal/texture-store-vector.slang
new file mode 100644
index 000000000..0f63b7ce3
--- /dev/null
+++ b/tests/metal/texture-store-vector.slang
@@ -0,0 +1,16 @@
+//TEST:SIMPLE(filecheck=CHECK): -target metal
+
+// Test that we can compile texture store operations with 2-component vectors
+// without segfaulting. This reproduces the issue where legalizeImageStoreValue
+// would crash when trying to expand a float2 to float4 for Metal texture writes.
+
+RWTexture2D<float2> output;
+
+[shader("compute")]
+[numthreads(32, 32, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ // This should expand float2(1,2) to float4(1,2,0,0)
+ // CHECK: {{.*}}float4(1.0, 2.0,
+ output.Store(dispatchThreadID.xy, float2(1, 2));
+} \ No newline at end of file