Skip to content

Commit 068cf20

Browse files
ngzhianCommit Bot
authored andcommitted
[wasm-simd] Implement floating-point roundings
Implement f32x4 and f64x2 nearest, trunc, ceil, and floor. These instructions were accepted into the proposal [0], this change removes all the ifdefs and todo guarding the prototypes, and moves these instructions out of the post-mvp flag. [0] WebAssembly/simd#232 Bug: v8:10906 Change-Id: I44ec21dd09f3bf7cf3cae5d35f70f9d2c178c4e4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2406547 Commit-Queue: Zhi An Ng <zhin@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Cr-Commit-Position: refs/heads/master@{#69923}
1 parent a53c1e4 commit 068cf20

3 files changed

Lines changed: 10 additions & 46 deletions

File tree

src/compiler/backend/instruction-selector.cc

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,22 +2686,6 @@ void InstructionSelector::VisitI64x2MinU(Node* node) { UNIMPLEMENTED(); }
26862686
void InstructionSelector::VisitI64x2MaxU(Node* node) { UNIMPLEMENTED(); }
26872687
#endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_S390X
26882688

2689-
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_S390X && \
2690-
!V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS && \
2691-
!V8_TARGET_ARCH_MIPS64
2692-
// TODO(v8:10553) Prototyping floating point rounding instructions.
2693-
void InstructionSelector::VisitF64x2Ceil(Node* node) { UNIMPLEMENTED(); }
2694-
void InstructionSelector::VisitF64x2Floor(Node* node) { UNIMPLEMENTED(); }
2695-
void InstructionSelector::VisitF64x2Trunc(Node* node) { UNIMPLEMENTED(); }
2696-
void InstructionSelector::VisitF64x2NearestInt(Node* node) { UNIMPLEMENTED(); }
2697-
void InstructionSelector::VisitF32x4Ceil(Node* node) { UNIMPLEMENTED(); }
2698-
void InstructionSelector::VisitF32x4Floor(Node* node) { UNIMPLEMENTED(); }
2699-
void InstructionSelector::VisitF32x4Trunc(Node* node) { UNIMPLEMENTED(); }
2700-
void InstructionSelector::VisitF32x4NearestInt(Node* node) { UNIMPLEMENTED(); }
2701-
#endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_S390X
2702-
// && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM &&
2703-
// !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64
2704-
27052689
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM64 && \
27062690
!V8_TARGET_ARCH_ARM
27072691
// TODO(v8:10583) Prototype i32x4.dot_i16x8_s

src/wasm/wasm-opcodes.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,15 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, const WasmFeatures&);
445445
V(I32x4SConvertF32x4, 0xfdf8, s_s) \
446446
V(I32x4UConvertF32x4, 0xfdf9, s_s) \
447447
V(F32x4SConvertI32x4, 0xfdfa, s_s) \
448-
V(F32x4UConvertI32x4, 0xfdfb, s_s)
448+
V(F32x4UConvertI32x4, 0xfdfb, s_s) \
449+
V(F32x4Ceil, 0xfdd8, s_s) \
450+
V(F32x4Floor, 0xfdd9, s_s) \
451+
V(F32x4Trunc, 0xfdda, s_s) \
452+
V(F32x4NearestInt, 0xfddb, s_s) \
453+
V(F64x2Ceil, 0xfddc, s_s) \
454+
V(F64x2Floor, 0xfddd, s_s) \
455+
V(F64x2Trunc, 0xfdde, s_s) \
456+
V(F64x2NearestInt, 0xfddf, s_s)
449457

450458
#define FOREACH_SIMD_POST_MVP_MEM_OPCODE(V) \
451459
V(S128LoadMem32Zero, 0xfdfc, s_i) \
@@ -478,15 +486,7 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, const WasmFeatures&);
478486
V(I32x4DotI16x8S, 0xfdba, s_ss) \
479487
V(F32x4AddHoriz, 0xfdb2, s_ss) \
480488
V(F32x4RecipApprox, 0xfdb3, s_s) \
481-
V(F32x4RecipSqrtApprox, 0xfdbc, s_s) \
482-
V(F32x4Ceil, 0xfdd8, s_s) \
483-
V(F32x4Floor, 0xfdd9, s_s) \
484-
V(F32x4Trunc, 0xfdda, s_s) \
485-
V(F32x4NearestInt, 0xfddb, s_s) \
486-
V(F64x2Ceil, 0xfddc, s_s) \
487-
V(F64x2Floor, 0xfddd, s_s) \
488-
V(F64x2Trunc, 0xfdde, s_s) \
489-
V(F64x2NearestInt, 0xfddf, s_s)
489+
V(F32x4RecipSqrtApprox, 0xfdbc, s_s)
490490

491491
#define FOREACH_SIMD_1_OPERAND_1_PARAM_OPCODE(V) \
492492
V(I8x16ExtractLaneS, 0xfd15, _) \

test/cctest/wasm/test-run-wasm-simd.cc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -680,33 +680,22 @@ WASM_SIMD_TEST(F32x4RecipSqrtApprox) {
680680
base::RecipSqrt, false /* !exact */);
681681
}
682682

683-
// TODO(v8:10553) Prototyping floating-point rounding instructions.
684-
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X || \
685-
V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || \
686-
V8_TARGET_ARCH_MIPS64
687683
WASM_SIMD_TEST_NO_LOWERING(F32x4Ceil) {
688-
FLAG_SCOPE(wasm_simd_post_mvp);
689684
RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4Ceil, ceilf, true);
690685
}
691686

692687
WASM_SIMD_TEST_NO_LOWERING(F32x4Floor) {
693-
FLAG_SCOPE(wasm_simd_post_mvp);
694688
RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4Floor, floorf, true);
695689
}
696690

697691
WASM_SIMD_TEST_NO_LOWERING(F32x4Trunc) {
698-
FLAG_SCOPE(wasm_simd_post_mvp);
699692
RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4Trunc, truncf, true);
700693
}
701694

702695
WASM_SIMD_TEST_NO_LOWERING(F32x4NearestInt) {
703-
FLAG_SCOPE(wasm_simd_post_mvp);
704696
RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4NearestInt, nearbyintf,
705697
true);
706698
}
707-
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X ||
708-
// V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS ||
709-
// V8_TARGET_ARCH_MIPS64
710699

711700
void RunF32x4BinOpTest(TestExecutionTier execution_tier, LowerSimd lower_simd,
712701
WasmOpcode opcode, FloatBinOp expected_op) {
@@ -1311,31 +1300,22 @@ WASM_SIMD_TEST(F64x2Sqrt) {
13111300
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Sqrt, Sqrt);
13121301
}
13131302

1314-
// TODO(v8:10553) Prototyping floating-point rounding instructions.
1315-
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X || \
1316-
V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS64
13171303
WASM_SIMD_TEST_NO_LOWERING(F64x2Ceil) {
1318-
FLAG_SCOPE(wasm_simd_post_mvp);
13191304
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Ceil, ceil, true);
13201305
}
13211306

13221307
WASM_SIMD_TEST_NO_LOWERING(F64x2Floor) {
1323-
FLAG_SCOPE(wasm_simd_post_mvp);
13241308
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Floor, floor, true);
13251309
}
13261310

13271311
WASM_SIMD_TEST_NO_LOWERING(F64x2Trunc) {
1328-
FLAG_SCOPE(wasm_simd_post_mvp);
13291312
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2Trunc, trunc, true);
13301313
}
13311314

13321315
WASM_SIMD_TEST_NO_LOWERING(F64x2NearestInt) {
1333-
FLAG_SCOPE(wasm_simd_post_mvp);
13341316
RunF64x2UnOpTest(execution_tier, lower_simd, kExprF64x2NearestInt, nearbyint,
13351317
true);
13361318
}
1337-
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X ||
1338-
// V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS64
13391319

13401320
void RunF64x2BinOpTest(TestExecutionTier execution_tier, LowerSimd lower_simd,
13411321
WasmOpcode opcode, DoubleBinOp expected_op) {

0 commit comments

Comments
 (0)