Commit f111e0c5 authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

[wasm-simd] Fix byte order when setting mask values

Multi byte values get stored on native host order when
arrays are being constructed, however as Wasm is LE enforced,
they get reversed on BE machines during simd load. This causes
incorrect values loaded into vector registers.

This CL will force mask elements to be saved in byte sizes
to eliminate endianness issues.

Change-Id: I7f2e5017664234e01fc8b51a95cdd852a418b651
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2645586Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#72340}
parent 4abba6d5
......@@ -801,26 +801,22 @@ WASM_SIMD_TEST_NO_LOWERING(I8x16SignSelect) {
}
WASM_SIMD_TEST_NO_LOWERING(I16x8SignSelect) {
std::array<int16_t, kSimd128Size / 2> selection = {0x8000, 0, -1, 0,
0x8000, 0, -1, 0};
std::array<int8_t, kSimd128Size> mask;
memcpy(mask.data(), selection.data(), kSimd128Size);
std::array<int8_t, kSimd128Size> mask = {0, 0x80, 0, 0, -1, -1, 0, 0,
0, 0x80, 0, 0, -1, -1, 0, 0};
RunSignSelect<int16_t>(execution_tier, lower_simd, kExprI16x8SignSelect,
kExprI16x8Splat, mask);
}
WASM_SIMD_TEST_NO_LOWERING(I32x4SignSelect) {
std::array<int32_t, kSimd128Size / 4> selection = {0x80000000, 0, -1, 0};
std::array<int8_t, kSimd128Size> mask;
memcpy(mask.data(), selection.data(), kSimd128Size);
std::array<int8_t, kSimd128Size> mask = {0, 0, 0, 0x80, 0, 0, 0, 0,
-1, -1, -1, -1, 0, 0, 0, 0};
RunSignSelect<int32_t>(execution_tier, lower_simd, kExprI32x4SignSelect,
kExprI32x4Splat, mask);
}
WASM_SIMD_TEST_NO_LOWERING(I64x2SignSelect) {
std::array<int64_t, kSimd128Size / 8> selection = {0x8000000000000000, 0};
std::array<int8_t, kSimd128Size> mask;
memcpy(mask.data(), selection.data(), kSimd128Size);
std::array<int8_t, kSimd128Size> mask = {0, 0, 0, 0, 0, 0, 0, 0x80,
0, 0, 0, 0, 0, 0, 0, 0};
RunSignSelect<int64_t>(execution_tier, lower_simd, kExprI64x2SignSelect,
kExprI64x2Splat, mask);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment