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

[wasm-simd][scalar-lowering] Lower floating-point rounding ops

Missed this earlier when it was merged into the proposal.

f32x4 and f64x2 ceil, floor, trunc, nearestint. Also enable cctests.

Bug: v8:10507,v8:10906
Change-Id: I2de00e615cd63d81303649774db2a2ab800f6f72
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2461451Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70415}
parent d21c89bb
......@@ -178,7 +178,11 @@ void SimdScalarLowering::LowerGraph() {
V(F64x2Mul) \
V(F64x2Div) \
V(F64x2Min) \
V(F64x2Max)
V(F64x2Max) \
V(F64x2Ceil) \
V(F64x2Floor) \
V(F64x2Trunc) \
V(F64x2NearestInt)
#define FOREACH_FLOAT32X4_OPCODE(V) \
V(F32x4Splat) \
......@@ -197,7 +201,11 @@ void SimdScalarLowering::LowerGraph() {
V(F32x4Mul) \
V(F32x4Div) \
V(F32x4Min) \
V(F32x4Max)
V(F32x4Max) \
V(F32x4Ceil) \
V(F32x4Floor) \
V(F32x4Trunc) \
V(F32x4NearestInt)
#define FOREACH_FLOAT64x2_TO_INT64x2OPCODE(V) \
V(F64x2Eq) \
......@@ -1786,6 +1794,22 @@ void SimdScalarLowering::LowerNode(Node* node) {
F32X4_UNOP_CASE(Neg)
F32X4_UNOP_CASE(Sqrt)
#undef F32X4_UNOP_CASE
case IrOpcode::kF32x4Ceil: {
LowerUnaryOp(node, rep_type, machine()->Float32RoundUp().op());
break;
}
case IrOpcode::kF32x4Floor: {
LowerUnaryOp(node, rep_type, machine()->Float32RoundDown().op());
break;
}
case IrOpcode::kF32x4Trunc: {
LowerUnaryOp(node, rep_type, machine()->Float32RoundTruncate().op());
break;
}
case IrOpcode::kF32x4NearestInt: {
LowerUnaryOp(node, rep_type, machine()->Float32RoundTiesEven().op());
break;
}
case IrOpcode::kF32x4RecipApprox:
case IrOpcode::kF32x4RecipSqrtApprox: {
DCHECK_EQ(1, node->InputCount());
......@@ -1846,6 +1870,22 @@ void SimdScalarLowering::LowerNode(Node* node) {
LowerBinaryOp(node, rep_type, machine()->Float64Max());
break;
}
case IrOpcode::kF64x2Ceil: {
LowerUnaryOp(node, rep_type, machine()->Float64RoundUp().op());
break;
}
case IrOpcode::kF64x2Floor: {
LowerUnaryOp(node, rep_type, machine()->Float64RoundDown().op());
break;
}
case IrOpcode::kF64x2Trunc: {
LowerUnaryOp(node, rep_type, machine()->Float64RoundTruncate().op());
break;
}
case IrOpcode::kF64x2NearestInt: {
LowerUnaryOp(node, rep_type, machine()->Float64RoundTiesEven().op());
break;
}
case IrOpcode::kF64x2Splat:
case IrOpcode::kF32x4Splat:
case IrOpcode::kI64x2Splat:
......
......@@ -671,19 +671,19 @@ WASM_SIMD_TEST(F32x4RecipSqrtApprox) {
base::RecipSqrt, false /* !exact */);
}
WASM_SIMD_TEST_NO_LOWERING(F32x4Ceil) {
WASM_SIMD_TEST(F32x4Ceil) {
RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4Ceil, ceilf, true);
}
WASM_SIMD_TEST_NO_LOWERING(F32x4Floor) {
WASM_SIMD_TEST(F32x4Floor) {
RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4Floor, floorf, true);
}
WASM_SIMD_TEST_NO_LOWERING(F32x4Trunc) {
WASM_SIMD_TEST(F32x4Trunc) {
RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4Trunc, truncf, true);
}
WASM_SIMD_TEST_NO_LOWERING(F32x4NearestInt) {
WASM_SIMD_TEST(F32x4NearestInt) {
RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4NearestInt, nearbyintf,
true);
}
......@@ -1287,19 +1287,19 @@ WASM_SIMD_TEST(F64x2Sqrt) {
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Sqrt, Sqrt);
}
WASM_SIMD_TEST_NO_LOWERING(F64x2Ceil) {
WASM_SIMD_TEST(F64x2Ceil) {
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Ceil, ceil, true);
}
WASM_SIMD_TEST_NO_LOWERING(F64x2Floor) {
WASM_SIMD_TEST(F64x2Floor) {
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Floor, floor, true);
}
WASM_SIMD_TEST_NO_LOWERING(F64x2Trunc) {
WASM_SIMD_TEST(F64x2Trunc) {
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Trunc, trunc, true);
}
WASM_SIMD_TEST_NO_LOWERING(F64x2NearestInt) {
WASM_SIMD_TEST(F64x2NearestInt) {
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2NearestInt, nearbyint,
true);
}
......
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