From e771f1945ed692168a2634d66a0907acc9c68858 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Thu, 16 Jan 2025 19:23:35 +0200 Subject: C-like emitter: Add parenthesis when combining relational and bitwise… (#6070) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * C-like emitter: Add redundant parentheses in several cases This is required since the Dawn WGSL compiler requires parentheses even though precedence rules could resolve order of operations. This closes #6005. * Fix tests/metal/byte-address-buffer The output now includes parentheses around shift expressions appearing as operands in bitwise expressions, so update the test accordingly. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He --- tests/metal/byte-address-buffer.slang | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/metal/byte-address-buffer.slang b/tests/metal/byte-address-buffer.slang index d4b58061f..cf704f170 100644 --- a/tests/metal/byte-address-buffer.slang +++ b/tests/metal/byte-address-buffer.slang @@ -20,11 +20,11 @@ struct TestStruct void main_kernel(uint3 tid: SV_DispatchThreadID) { // CHECK: uint [[WORD0:[a-zA-Z0-9_]+]] = as_type({{.*}}[(int(0))>>2]); - // CHECK: uint8_t [[A:[a-zA-Z0-9_]+]] = uint8_t([[WORD0]] >> 0U & 255U); + // CHECK: uint8_t [[A:[a-zA-Z0-9_]+]] = uint8_t(([[WORD0]] >> 0U) & 255U); // CHECK: uint [[WORD1:[a-zA-Z0-9_]+]] = as_type({{.*}}[(int(0))>>2]); - // CHECK: half [[H:[a-zA-Z0-9_]+]] = as_type(ushort([[WORD1]] >> 16U & 65535U)); + // CHECK: half [[H:[a-zA-Z0-9_]+]] = as_type(ushort(([[WORD1]] >> 16U) & 65535U)); - // CHECK: {{.*}}[(int(128))>>2] = as_type(({{.*}} & 4294967040U) | uint([[A]]) << 0U); - // CHECK: {{.*}}[(int(128))>>2] = as_type(({{.*}} & 65535U) | uint(as_type([[H]])) << 16U); + // CHECK: {{.*}}[(int(128))>>2] = as_type(({{.*}} & 4294967040U) | (uint([[A]]) << 0U)); + // CHECK: {{.*}}[(int(128))>>2] = as_type(({{.*}} & 65535U) | (uint(as_type([[H]])) << 16U)); buffer.Store(128, buffer.Load(0)); } -- cgit v1.2.3