Fix i64x2 shift on big-endian (#8748)
Since the i64x2.sh* functions use i32 as shift argument the access to
`other.i64` may not use the correct union member. 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
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index 22fc544..8c5074e 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -1483,8 +1483,8 @@
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 @@
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 @@
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");
}