From 4157728312380c8e822565848f6a2ed1ccc43cd5 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Thu, 24 Sep 2020 14:10:59 -0700 Subject: [PATCH] [wasm-simd][scalar-lowering] Implement more replacement conversions f32x4->16x8, 64x2->8x16, and 16x8->8x16. This allows us to pass more spec tests. Bug: v8:10507 Change-Id: I1810ce2d17f93529b2e69cf5c767cb7b480b4b49 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2429807 Reviewed-by: Bill Budge Commit-Queue: Zhi An Ng Cr-Commit-Position: refs/heads/master@{#70128} --- src/compiler/simd-scalar-lowering.cc | 14 +++++++++++-- .../test-run-wasm-simd-scalar-lowering.cc | 20 +++++++++++++++++++ test/wasm-spec-tests/wasm-spec-tests.status | 2 -- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/compiler/simd-scalar-lowering.cc b/src/compiler/simd-scalar-lowering.cc index 52ed0be824..49606ed392 100644 --- a/src/compiler/simd-scalar-lowering.cc +++ b/src/compiler/simd-scalar-lowering.cc @@ -2338,13 +2338,23 @@ Node** SimdScalarLowering::GetReplacementsWithType(Node* node, SimdType type) { if (ReplacementType(node) == SimdType::kInt32x4) { Int32ToSmallerInt(replacements, result); } else if (ReplacementType(node) == SimdType::kFloat32x4) { - UNIMPLEMENTED(); + Node** float32_to_int32 = zone()->NewArray(kNumLanes32); + Float32ToInt32(replacements, float32_to_int32); + Int32ToSmallerInt(float32_to_int32, result); } else { UNREACHABLE(); } } else if (type == SimdType::kInt8x16) { - if (ReplacementType(node) == SimdType::kInt32x4) { + if (ReplacementType(node) == SimdType::kInt64x2) { + Node** int64_to_int32 = zone()->NewArray(kNumLanes32); + Int64ToInt32(replacements, int64_to_int32); + Int32ToSmallerInt(int64_to_int32, result); + } else if (ReplacementType(node) == SimdType::kInt32x4) { Int32ToSmallerInt(replacements, result); + } else if (ReplacementType(node) == SimdType::kInt16x8) { + Node** int16_to_int32 = zone()->NewArray(kNumLanes32); + SmallerIntToInt32(replacements, int16_to_int32); + Int32ToSmallerInt(int16_to_int32, result); } else { UNIMPLEMENTED(); } diff --git a/test/cctest/wasm/test-run-wasm-simd-scalar-lowering.cc b/test/cctest/wasm/test-run-wasm-simd-scalar-lowering.cc index a4f9c8f7dd..d03d4cd3e6 100644 --- a/test/cctest/wasm/test-run-wasm-simd-scalar-lowering.cc +++ b/test/cctest/wasm/test-run-wasm-simd-scalar-lowering.cc @@ -206,6 +206,16 @@ WASM_SIMD_TEST(AllTrue_DifferentShapes) { CHECK_EQ(0, r.Call(0x000000FF)); } + + // Check float input to all_true. + { + WasmRunner r(execution_tier, lower_simd); + + BUILD(r, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(0)), + WASM_SIMD_OP(kExprV16x8AllTrue)); + + CHECK_EQ(1, r.Call(0x000F000F)); + } } WASM_SIMD_TEST(AnyTrue_DifferentShapes) { @@ -227,6 +237,16 @@ WASM_SIMD_TEST(AnyTrue_DifferentShapes) { CHECK_EQ(1, r.Call(0x000000FF)); } + + // Check float input to any_true. + { + WasmRunner r(execution_tier, lower_simd); + + BUILD(r, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(0)), + WASM_SIMD_OP(kExprV8x16AnyTrue)); + + CHECK_EQ(0, r.Call(0x00000000)); + } } } // namespace test_run_wasm_simd diff --git a/test/wasm-spec-tests/wasm-spec-tests.status b/test/wasm-spec-tests/wasm-spec-tests.status index d3bde5cae1..70f67bf4b5 100644 --- a/test/wasm-spec-tests/wasm-spec-tests.status +++ b/test/wasm-spec-tests/wasm-spec-tests.status @@ -40,10 +40,8 @@ # SIMD test cases # Scalar lowering is incomplete, we skip these and selectively enable as # we finish the implementation, see v8:10507. - 'proposals/simd/simd_bit_shift' : [PASS, FAIL], 'proposals/simd/simd_conversions' : [PASS, FAIL], 'proposals/simd/simd_lane' : [PASS, FAIL], - 'proposals/simd/simd_load_extend' : [PASS, FAIL], 'proposals/simd/simd_load_splat' : [PASS, FAIL], 'proposals/simd/simd_splat' : [PASS, FAIL],