mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWasm: Fix SIMD shuffle and swizzle
`swizzle` had the wrong operands, and the vector masking boolean logic was incorrect in the internal `shuffle_or_0` implementation. `shuffle` was previously implemented as a dynamic swizzle, when it uses an immediate operand for lane indices in the spec.
This commit is contained in:
parent
d841742c35
commit
9cc3e7d32d
Notes:
github-actions[bot]
2024-07-24 21:24:08 +00:00
Author: https://github.com/dzfrias
Commit: 9cc3e7d32d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/794
Reviewed-by: https://github.com/alimpfard
3 changed files with 15 additions and 9 deletions
|
@ -1289,12 +1289,17 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
|
|||
case Instructions::f64x2_splat.value():
|
||||
return pop_and_push_m_splat<64, NativeFloatingType>(configuration, instruction);
|
||||
case Instructions::i8x16_shuffle.value(): {
|
||||
auto indices = pop_vector<u8, MakeSigned>(configuration);
|
||||
TRAP_IF_NOT(indices.has_value());
|
||||
auto vector = peek_vector<u8, MakeSigned>(configuration);
|
||||
TRAP_IF_NOT(vector.has_value());
|
||||
auto result = shuffle_vector(vector.value(), indices.value());
|
||||
configuration.stack().peek() = Value(result);
|
||||
auto& arg = instruction.arguments().get<Instruction::ShuffleArgument>();
|
||||
auto b = *pop_vector<u8, MakeUnsigned>(configuration);
|
||||
auto a = *pop_vector<u8, MakeUnsigned>(configuration);
|
||||
using VectorType = Native128ByteVectorOf<u8, MakeUnsigned>;
|
||||
VectorType result;
|
||||
for (size_t i = 0; i < 16; ++i)
|
||||
if (arg.lanes[i] < 16)
|
||||
result[i] = a[arg.lanes[i]];
|
||||
else
|
||||
result[i] = b[arg.lanes[i] - 16];
|
||||
configuration.stack().push(Value(bit_cast<u128>(result)));
|
||||
return;
|
||||
}
|
||||
case Instructions::v128_store.value():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue