Commit 0b36f190 authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

[wasm-simd][scalar-lowering] Fix lowering on BE machines

As WASM is LE enforced, data is originally written to memory
in LE order regardless of the machine type, therefore we need
to read it back the same way.

Bug: v8:10507
Change-Id: I72896eeeed177a22ca87e8c380f99dca795ddc4a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2410475
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69896}
parent b1281b32
......@@ -1210,8 +1210,10 @@ void SimdScalarLowering::LowerNode(Node* node) {
switch (rep_type) {
case SimdType::kInt8x16: {
for (int i = 0; i < num_lanes; ++i) {
Address data_address = reinterpret_cast<Address>(params.data() + i);
rep_node[i] = mcgraph_->Int32Constant(
static_cast<int32_t>(static_cast<int8_t>(params.data()[i])));
static_cast<int32_t>(static_cast<int8_t>(
base::ReadLittleEndianValue<int8_t>(data_address))));
}
break;
}
......@@ -1219,7 +1221,8 @@ void SimdScalarLowering::LowerNode(Node* node) {
int16_t val[kNumLanes16];
memcpy(val, params.data(), kSimd128Size);
for (int i = 0; i < num_lanes; ++i) {
rep_node[i] = mcgraph_->Int32Constant(static_cast<int32_t>(val[i]));
rep_node[i] = mcgraph_->Int32Constant(static_cast<int32_t>(
base::ReadLittleEndianValue<int16_t>(&val[i])));
}
break;
}
......@@ -1227,7 +1230,8 @@ void SimdScalarLowering::LowerNode(Node* node) {
uint32_t val[kNumLanes32];
memcpy(val, params.data(), kSimd128Size);
for (int i = 0; i < num_lanes; ++i) {
rep_node[i] = mcgraph_->Int32Constant(val[i]);
rep_node[i] = mcgraph_->Int32Constant(
base::ReadLittleEndianValue<uint32_t>(&val[i]));
}
break;
}
......
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