From 75135a0aad40b805b7d8df4da4fb45c77477248d Mon Sep 17 00:00:00 2001 From: Sertonix Date: Thu, 21 May 2026 13:57:11 +0200 Subject: [PATCH] Fix i64x2 shift on big-endian The i64x2 shift functions use i32 for the second argument. This makes the other.i64 not always match other.type. On big-endian systems this causes tests in test/spec/testsuite/simd_bit_shift.wast and a few other places to fail. Ref https://github.com/WebAssembly/binaryen/issues/2983 --- src/wasm/literal.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 22fc5447e1f..8c5074e1c74 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -1483,8 +1483,8 @@ Literal Literal::shl(const Literal& other) const { return Literal(uint32_t(i32) << Bits::getEffectiveShifts(other.i32, Type::i32)); case Type::i64: - return Literal(uint64_t(i64) - << Bits::getEffectiveShifts(other.i64, Type::i64)); + return Literal(uint64_t(i64) << Bits::getEffectiveShifts( + other.getInteger(), Type::i64)); default: WASM_UNREACHABLE("unexpected type"); } @@ -1495,7 +1495,8 @@ Literal Literal::shrS(const Literal& other) const { case Type::i32: return Literal(i32 >> Bits::getEffectiveShifts(other.i32, Type::i32)); case Type::i64: - return Literal(i64 >> Bits::getEffectiveShifts(other.i64, Type::i64)); + return Literal(i64 >> + Bits::getEffectiveShifts(other.getInteger(), Type::i64)); default: WASM_UNREACHABLE("unexpected type"); } @@ -1508,7 +1509,7 @@ Literal Literal::shrU(const Literal& other) const { Bits::getEffectiveShifts(other.i32, Type::i32)); case Type::i64: return Literal(uint64_t(i64) >> - Bits::getEffectiveShifts(other.i64, Type::i64)); + Bits::getEffectiveShifts(other.getInteger(), Type::i64)); default: WASM_UNREACHABLE("unexpected type"); }