Commit 880ca119 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Fix detection of Simd128 globals in compiler.

This makes sure that the {WasmGraphBuilder} properly detects the
presence of Simd128 global.get and global.set opcodes and triggers
scalar lowering on architectures without Simd128 support.

R=clemensb@chromium.org
TEST=cctest/test-run-wasm-simd/RunWasm_S128Globals
BUG=v8:9973

Change-Id: I1538bd1d3fea40cc78e82b125d4f113842faf68a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1917148Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65002}
parent 37e62175
......@@ -3322,6 +3322,9 @@ Node* WasmGraphBuilder::GlobalGet(uint32_t index) {
MachineType mem_type =
wasm::ValueTypes::MachineTypeFor(env_->module->globals[index].type);
if (mem_type.representation() == MachineRepresentation::kSimd128) {
has_simd_ = true;
}
Node* base = nullptr;
Node* offset = nullptr;
GetGlobalBaseAndOffset(mem_type, env_->module->globals[index], &base,
......@@ -3354,6 +3357,9 @@ Node* WasmGraphBuilder::GlobalSet(uint32_t index, Node* val) {
MachineType mem_type =
wasm::ValueTypes::MachineTypeFor(env_->module->globals[index].type);
if (mem_type.representation() == MachineRepresentation::kSimd128) {
has_simd_ = true;
}
Node* base = nullptr;
Node* offset = nullptr;
GetGlobalBaseAndOffset(mem_type, env_->module->globals[index], &base,
......
......@@ -526,6 +526,26 @@ bool IsExtreme(float x) {
(abs_x < kSmallFloatThreshold || abs_x > kLargeFloatThreshold);
}
WASM_SIMD_TEST(S128Globals) {
WasmRunner<int32_t> r(execution_tier, lower_simd);
// Set up a global to hold input and output vectors.
int32_t* g0 = r.builder().AddGlobal<int32_t>(kWasmS128);
int32_t* g1 = r.builder().AddGlobal<int32_t>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(1, WASM_GET_GLOBAL(0)), WASM_ONE);
FOR_INT32_INPUTS(x) {
for (int i = 0; i < 4; i++) {
WriteLittleEndianValue<int32_t>(&g0[i], x);
}
r.Call();
int32_t expected = x;
for (int i = 0; i < 4; i++) {
int32_t actual = ReadLittleEndianValue<int32_t>(&g1[i]);
CHECK_EQ(actual, expected);
}
}
}
WASM_SIMD_TEST(F32x4Splat) {
WasmRunner<int32_t, float> r(execution_tier, lower_simd);
// Set up a global to hold output vector.
......
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