Commit 6a3e92e9 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[wasm-simd] Scalar lowering to convert i8x16 to f32x4

Implement conversion of an i8x16 node to a f32x4 node.

Bug: v8:10507
Change-Id: Ifefffb779dbf25b57eae278afe41c11b41c949ac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2185472Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67659}
parent 5d8f9039
......@@ -1833,6 +1833,9 @@ Node** SimdScalarLowering::GetReplacementsWithType(Node* node, SimdType type) {
Int32ToFloat32(replacements, result);
} else if (ReplacementType(node) == SimdType::kInt16x8) {
UNIMPLEMENTED();
} else if (ReplacementType(node) == SimdType::kInt8x16) {
SmallerIntToInt32<int8_t>(replacements, result);
Int32ToFloat32(result, result);
} else {
UNREACHABLE();
}
......
......@@ -290,6 +290,7 @@ v8_source_set("cctest_sources") {
"wasm/test-run-wasm-module.cc",
"wasm/test-run-wasm-sign-extension.cc",
"wasm/test-run-wasm-simd-liftoff.cc",
"wasm/test-run-wasm-simd-scalar-lowering.cc",
"wasm/test-run-wasm-simd.cc",
"wasm/test-run-wasm.cc",
"wasm/test-streaming-compilation.cc",
......
......@@ -484,6 +484,7 @@
'test-run-wasm-module/*': [SKIP],
'test-run-wasm-sign-extension/*': [SKIP],
'test-run-wasm-simd-liftoff/*': [SKIP],
'test-run-wasm-simd-scalar-lowering/*': [SKIP],
'test-run-wasm-simd/*': [SKIP],
'test-streaming-compilation/*': [SKIP],
'test-wasm-breakpoints/*': [SKIP],
......
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/wasm/compilation-environment.h"
#include "src/wasm/wasm-tier.h"
#include "test/cctest/cctest.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/flag-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {
namespace wasm {
namespace test_run_wasm_simd {
#define WASM_SIMD_TEST(name) \
void RunWasm_##name##_Impl(LowerSimd lower_simd, \
ExecutionTier execution_tier); \
TEST(RunWasm_##name##_simd_lowered) { \
EXPERIMENTAL_FLAG_SCOPE(simd); \
RunWasm_##name##_Impl(kLowerSimd, ExecutionTier::kTurbofan); \
} \
void RunWasm_##name##_Impl(LowerSimd lower_simd, ExecutionTier execution_tier)
WASM_SIMD_TEST(I8x16ToF32x4) {
WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd);
float* g = r.builder().AddGlobal<float>(kWasmS128);
byte param1 = 0;
BUILD(r,
WASM_SET_GLOBAL(
0, WASM_SIMD_UNOP(kExprF32x4Sqrt,
WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(param1)))),
WASM_ONE);
// Arbitrary pattern that doesn't end up creating a NaN.
r.Call(0x5b);
float f = bit_cast<float>(0x5b5b5b5b);
float actual = ReadLittleEndianValue<float>(&g[0]);
float expected = std::sqrt(f);
CHECK_EQ(expected, actual);
}
} // namespace test_run_wasm_simd
} // namespace wasm
} // namespace internal
} // namespace v8
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