Commit 3512721c authored by jing.bao's avatar jing.bao Committed by Commit Bot

[wasm]implement simd lowering for F32x4RecipApprox/F32x4RecipSqrtApprox

Change-Id: I53136c1c296b112e9521fa21e85e945267e51059
Reviewed-on: https://chromium-review.googlesource.com/963702Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Reviewed-by: 's avatarAseem Garg <aseemgarg@chromium.org>
Commit-Queue: Jing Bao <jing.bao@intel.com>
Cr-Commit-Position: refs/heads/master@{#52086}
parent 767b8edd
......@@ -116,6 +116,8 @@ void SimdScalarLowering::LowerGraph() {
V(F32x4UConvertI32x4) \
V(F32x4Abs) \
V(F32x4Neg) \
V(F32x4RecipApprox) \
V(F32x4RecipSqrtApprox) \
V(F32x4Add) \
V(F32x4AddHoriz) \
V(F32x4Sub) \
......@@ -1024,6 +1026,22 @@ void SimdScalarLowering::LowerNode(Node* node) {
F32X4_UNOP_CASE(Abs)
F32X4_UNOP_CASE(Neg)
#undef F32x4_UNOP_CASE
case IrOpcode::kF32x4RecipApprox:
case IrOpcode::kF32x4RecipSqrtApprox: {
DCHECK_EQ(1, node->InputCount());
Node** rep = GetReplacementsWithType(node->InputAt(0), rep_type);
Node** rep_node = zone()->NewArray<Node*>(num_lanes);
Node* float_one = graph()->NewNode(common()->Float32Constant(1.0));
for (int i = 0; i < num_lanes; ++i) {
Node* tmp = rep[i];
if (node->opcode() == IrOpcode::kF32x4RecipSqrtApprox) {
tmp = graph()->NewNode(machine()->Float32Sqrt(), rep[i]);
}
rep_node[i] = graph()->NewNode(machine()->Float32Div(), float_one, tmp);
}
ReplaceNode(node, rep_node, num_lanes);
break;
}
case IrOpcode::kF32x4SConvertI32x4: {
LowerUnaryOp(node, SimdType::kInt32x4, machine()->RoundInt32ToFloat32());
break;
......
......@@ -505,11 +505,11 @@ WASM_SIMD_TEST(F32x4Neg) {
V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_X64
static const float kApproxError = 0.01f;
WASM_SIMD_COMPILED_TEST(F32x4RecipApprox) {
WASM_SIMD_TEST(F32x4RecipApprox) {
RunF32x4UnOpTest(lower_simd, kExprF32x4RecipApprox, Recip, kApproxError);
}
WASM_SIMD_COMPILED_TEST(F32x4RecipSqrtApprox) {
WASM_SIMD_TEST(F32x4RecipSqrtApprox) {
RunF32x4UnOpTest(lower_simd, kExprF32x4RecipSqrtApprox, RecipSqrt,
kApproxError);
}
......
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