From 48efc60380aa79e8c4aba13976cc2015f38a659e Mon Sep 17 00:00:00 2001 From: Gangzheng Tong Date: Tue, 29 Jul 2025 12:12:40 -0700 Subject: Fix Metal invalid as_type cast for 64-bit RWByteAddressBuffer.Store values (#7843) * Fix 64-bit val lowering for metal * Add ByteAddressBuffer load/store 64-bit tests * Handle Store/Load ptr types * Use bitcast for non-pointer typers * format code (#7966) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- tests/metal/byte-address-buffer.slang | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'tests/metal') diff --git a/tests/metal/byte-address-buffer.slang b/tests/metal/byte-address-buffer.slang index 53c0e0ac5..8514dafe6 100644 --- a/tests/metal/byte-address-buffer.slang +++ b/tests/metal/byte-address-buffer.slang @@ -1,8 +1,6 @@ //TEST:SIMPLE(filecheck=CHECK): -target metal //TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib -uniform RWStructuredBuffer outputBuffer; - RWByteAddressBuffer buffer; // CHECK-ASM: define void @main_kernel @@ -27,4 +25,24 @@ void main_kernel(uint3 tid: SV_DispatchThreadID) // CHECK: {{.*}}[(128U)>>2] = as_type(({{.*}} & 4294967040U) | (uint([[A]]) << 0U)); // CHECK: {{.*}}[(128U)>>2] = as_type(({{.*}} & 65535U) | (uint(as_type([[H]])) << 16U)); buffer.Store(128, buffer.Load(0)); + + // CHECK: {{.*}}[(256U)>>2] = as_type(4294967295U); + // CHECK: {{.*}}[(260U)>>2] = as_type(4294967295U); + int64_t i64 = -1; + buffer.Store(256, i64); + + // CHECK: {{.*}}[(264U)>>2] = as_type(123U); + // CHECK: {{.*}}[(268U)>>2] = as_type(0U); + uint64_t u64 = 123; + buffer.Store(264, u64); + + int64_t* ptr = Ptr(0xFF); + // CHECK: {{.*}}[(272U)>>2] = as_type({{.*}}); + // CHECK: {{.*}}[(276U)>>2] = as_type({{.*}}); + buffer.Store(272, ptr); + + // CHECK: {{.*}}[(280U)>>2] = as_type(4294967295U); + // CHECK: {{.*}}[(284U)>>2] = as_type(4294967295U); + uintptr_t uintptr_val = (uintptr_t)-1; + buffer.Store(280, uintptr_val); } -- cgit v1.2.3