Commit e4d77e9c authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[wasm-simd][scalar-lowering] Fix v128.const lowering for f32x4

We need to construct Float32 nodes for f32x4, using Word32 operators
will cause the wrong register to be allocated, triggering a CHECK
failure.

Bug: v8:10507
Change-Id: I70842f1d61b90fed2407ee52af4bc5a6b1b82ba6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2399050Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69856}
parent 3ba44311
......@@ -1201,8 +1201,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
}
break;
}
case SimdType::kInt32x4:
case SimdType::kFloat32x4: {
case SimdType::kInt32x4: {
uint32_t val[kNumLanes32];
memcpy(val, params.data(), kSimd128Size);
for (int i = 0; i < num_lanes; ++i) {
......@@ -1210,6 +1209,14 @@ void SimdScalarLowering::LowerNode(Node* node) {
}
break;
}
case SimdType::kFloat32x4: {
float val[kNumLanes32];
memcpy(val, params.data(), kSimd128Size);
for (int i = 0; i < num_lanes; ++i) {
rep_node[i] = mcgraph_->Float32Constant(val[i]);
}
break;
}
default: {
UNIMPLEMENTED();
}
......
......@@ -124,6 +124,27 @@ WASM_SIMD_TEST(I8x16Eq_ToTest_S128Const) {
CHECK_EQ(0xffffffff, r.Call());
}
WASM_SIMD_TEST(F32x4_S128Const) {
// Test that S128Const lowering is done correctly when it is used as an input
// into a f32x4 operation. This was triggering a CHECK failure in the
// register-allocator-verifier.
TestSignatures sigs;
WasmRunner<float> r(execution_tier, lower_simd);
// f32x4(1.0, 2.0, 3.0, 4.0)
byte c1[16] = {0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x40,
0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x80, 0x40};
// f32x4(5.0, 6.0, 7.0, 8.0)
byte c2[16] = {0x00, 0x00, 0xa0, 0x40, 0x00, 0x00, 0xc0, 0x40,
0x00, 0x00, 0xe0, 0x40, 0x00, 0x00, 0x00, 0x41};
BUILD(r,
WASM_SIMD_BINOP(kExprF32x4Min, WASM_SIMD_CONSTANT(c1),
WASM_SIMD_CONSTANT(c2)),
WASM_SIMD_OP(kExprF32x4ExtractLane), TO_BYTE(0));
CHECK_EQ(1.0, r.Call());
}
} // namespace test_run_wasm_simd
} // namespace wasm
} // namespace internal
......
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