diff options
| author | Anders Leino <aleino@nvidia.com> | 2025-01-16 19:23:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-16 09:23:35 -0800 |
| commit | e771f1945ed692168a2634d66a0907acc9c68858 (patch) | |
| tree | e8d6de4ad801b5dc68cd07638f27efa2e5664426 /tests | |
| parent | ad7d13a8a934a56db87a4ece4b1afb0f1db1c9d9 (diff) | |
C-like emitter: Add parenthesis when combining relational and bitwise… (#6070)
* 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 <yonghe@outlook.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/metal/byte-address-buffer.slang | 8 |
1 files changed, 4 insertions, 4 deletions
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<uint>({{.*}}[(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<uint>({{.*}}[(int(0))>>2]); - // CHECK: half [[H:[a-zA-Z0-9_]+]] = as_type<half>(ushort([[WORD1]] >> 16U & 65535U)); + // CHECK: half [[H:[a-zA-Z0-9_]+]] = as_type<half>(ushort(([[WORD1]] >> 16U) & 65535U)); - // CHECK: {{.*}}[(int(128))>>2] = as_type<uint32_t>(({{.*}} & 4294967040U) | uint([[A]]) << 0U); - // CHECK: {{.*}}[(int(128))>>2] = as_type<uint32_t>(({{.*}} & 65535U) | uint(as_type<ushort>([[H]])) << 16U); + // CHECK: {{.*}}[(int(128))>>2] = as_type<uint32_t>(({{.*}} & 4294967040U) | (uint([[A]]) << 0U)); + // CHECK: {{.*}}[(int(128))>>2] = as_type<uint32_t>(({{.*}} & 65535U) | (uint(as_type<ushort>([[H]])) << 16U)); buffer.Store(128, buffer.Load<TestStruct>(0)); } |
