Skip to content

Commit 237be34

Browse files
committed
[WebAssembly] Improve macro hygiene in wasm_simd128.h
Summary: The shuffle intrinsic macros did not parenthesize usages of their constant parameters, which could lead to incorrect results due to operator precedence issues. This patch fixes the problem by adding the missing paretheses. Reviewers: aheejin Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80968
1 parent b836ae2 commit 237be34

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

clang/lib/Headers/wasm_simd128.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,24 +1034,24 @@ wasm_f32x4_convert_u32x4(v128_t __a) {
10341034
#define wasm_v16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \
10351035
__c7) \
10361036
((v128_t)__builtin_wasm_shuffle_v8x16( \
1037-
(__i8x16)(__a), (__i8x16)(__b), __c0 * 2, __c0 * 2 + 1, __c1 * 2, \
1038-
__c1 * 2 + 1, __c2 * 2, __c2 * 2 + 1, __c3 * 2, __c3 * 2 + 1, __c4 * 2, \
1039-
__c4 * 2 + 1, __c5 * 2, __c5 * 2 + 1, __c6 * 2, __c6 * 2 + 1, __c7 * 2, \
1040-
__c7 * 2 + 1))
1037+
(__i8x16)(__a), (__i8x16)(__b), (__c0)*2, (__c0)*2 + 1, (__c1)*2, \
1038+
(__c1)*2 + 1, (__c2)*2, (__c2)*2 + 1, (__c3)*2, (__c3)*2 + 1, (__c4)*2, \
1039+
(__c4)*2 + 1, (__c5)*2, (__c5)*2 + 1, (__c6)*2, (__c6)*2 + 1, (__c7)*2, \
1040+
(__c7)*2 + 1))
10411041

10421042
#define wasm_v32x4_shuffle(__a, __b, __c0, __c1, __c2, __c3) \
10431043
((v128_t)__builtin_wasm_shuffle_v8x16( \
1044-
(__i8x16)(__a), (__i8x16)(__b), __c0 * 4, __c0 * 4 + 1, __c0 * 4 + 2, \
1045-
__c0 * 4 + 3, __c1 * 4, __c1 * 4 + 1, __c1 * 4 + 2, __c1 * 4 + 3, \
1046-
__c2 * 4, __c2 * 4 + 1, __c2 * 4 + 2, __c2 * 4 + 3, __c3 * 4, \
1047-
__c3 * 4 + 1, __c3 * 4 + 2, __c3 * 4 + 3))
1044+
(__i8x16)(__a), (__i8x16)(__b), (__c0)*4, (__c0)*4 + 1, (__c0)*4 + 2, \
1045+
(__c0)*4 + 3, (__c1)*4, (__c1)*4 + 1, (__c1)*4 + 2, (__c1)*4 + 3, \
1046+
(__c2)*4, (__c2)*4 + 1, (__c2)*4 + 2, (__c2)*4 + 3, (__c3)*4, \
1047+
(__c3)*4 + 1, (__c3)*4 + 2, (__c3)*4 + 3))
10481048

10491049
#define wasm_v64x2_shuffle(__a, __b, __c0, __c1) \
10501050
((v128_t)__builtin_wasm_shuffle_v8x16( \
1051-
(__i8x16)(__a), (__i8x16)(__b), __c0 * 8, __c0 * 8 + 1, __c0 * 8 + 2, \
1052-
__c0 * 8 + 3, __c0 * 8 + 4, __c0 * 8 + 5, __c0 * 8 + 6, __c0 * 8 + 7, \
1053-
__c1 * 8, __c1 * 8 + 1, __c1 * 8 + 2, __c1 * 8 + 3, __c1 * 8 + 4, \
1054-
__c1 * 8 + 5, __c1 * 8 + 6, __c1 * 8 + 7))
1051+
(__i8x16)(__a), (__i8x16)(__b), (__c0)*8, (__c0)*8 + 1, (__c0)*8 + 2, \
1052+
(__c0)*8 + 3, (__c0)*8 + 4, (__c0)*8 + 5, (__c0)*8 + 6, (__c0)*8 + 7, \
1053+
(__c1)*8, (__c1)*8 + 1, (__c1)*8 + 2, (__c1)*8 + 3, (__c1)*8 + 4, \
1054+
(__c1)*8 + 5, (__c1)*8 + 6, (__c1)*8 + 7))
10551055

10561056
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v8x16_swizzle(v128_t __a,
10571057
v128_t __b) {

0 commit comments

Comments
 (0)