Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: test/cctest/wasm/test-run-wasm-simd.cc

Issue 2827143002: [WASM SIMD] Remove opcodes that are slow on some platforms. (Closed)
Patch Set: Remove stray tests. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-opcodes.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/assembler-inl.h" 5 #include "src/assembler-inl.h"
6 #include "src/wasm/wasm-macro-gen.h" 6 #include "src/wasm/wasm-macro-gen.h"
7 #include "test/cctest/cctest.h" 7 #include "test/cctest/cctest.h"
8 #include "test/cctest/compiler/value-helper.h" 8 #include "test/cctest/compiler/value-helper.h"
9 #include "test/cctest/wasm/wasm-run-utils.h" 9 #include "test/cctest/wasm/wasm-run-utils.h"
10 10
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 template <typename T> 259 template <typename T>
260 T Recip(T a) { 260 T Recip(T a) {
261 return 1.0f / a; 261 return 1.0f / a;
262 } 262 }
263 263
264 template <typename T> 264 template <typename T>
265 T RecipSqrt(T a) { 265 T RecipSqrt(T a) {
266 return 1.0f / std::sqrt(a); 266 return 1.0f / std::sqrt(a);
267 } 267 }
268 268
269 template <typename T>
270 T RecipRefine(T a, T b) {
271 return 2.0f - a * b;
272 }
273
274 template <typename T>
275 T RecipSqrtRefine(T a, T b) {
276 return (3.0f - a * b) * 0.5f;
277 }
278
279 } // namespace 269 } // namespace
280 270
281 #define WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lane_value, lane_index) \ 271 #define WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lane_value, lane_index) \
282 WASM_IF(WASM_##LANE_TYPE##_NE(WASM_GET_LOCAL(lane_value), \ 272 WASM_IF(WASM_##LANE_TYPE##_NE(WASM_GET_LOCAL(lane_value), \
283 WASM_SIMD_##TYPE##_EXTRACT_LANE( \ 273 WASM_SIMD_##TYPE##_EXTRACT_LANE( \
284 lane_index, WASM_GET_LOCAL(value))), \ 274 lane_index, WASM_GET_LOCAL(value))), \
285 WASM_RETURN1(WASM_ZERO)) 275 WASM_RETURN1(WASM_ZERO))
286 276
287 #define WASM_SIMD_CHECK4(TYPE, value, LANE_TYPE, lv0, lv1, lv2, lv3) \ 277 #define WASM_SIMD_CHECK4(TYPE, value, LANE_TYPE, lv0, lv1, lv2, lv3) \
288 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv0, 0) \ 278 WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lv0, 0) \
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 float abs_error = std::abs(expected) * error; 499 float abs_error = std::abs(expected) * error;
510 CHECK_EQ(1, r.Call(*i, expected - abs_error, expected + abs_error)); 500 CHECK_EQ(1, r.Call(*i, expected - abs_error, expected + abs_error));
511 } 501 }
512 } 502 }
513 503
514 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } 504 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); }
515 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } 505 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); }
516 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || 506 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
517 // V8_TARGET_ARCH_MIPS64 507 // V8_TARGET_ARCH_MIPS64
518 508
519 #if SIMD_LOWERING_TARGET
520 WASM_EXEC_COMPILED_TEST(F32x4Sqrt) { RunF32x4UnOpTest(kExprF32x4Sqrt, Sqrt); }
521 #endif // SIMD_LOWERING_TARGET
522
523 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 509 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
524 static const float kApproxError = 0.01f; 510 static const float kApproxError = 0.01f;
525 511
526 WASM_EXEC_COMPILED_TEST(F32x4RecipApprox) { 512 WASM_EXEC_COMPILED_TEST(F32x4RecipApprox) {
527 RunF32x4UnOpTest(kExprF32x4RecipApprox, Recip, kApproxError); 513 RunF32x4UnOpTest(kExprF32x4RecipApprox, Recip, kApproxError);
528 } 514 }
529 515
530 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtApprox) { 516 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtApprox) {
531 RunF32x4UnOpTest(kExprF32x4RecipSqrtApprox, RecipSqrt, kApproxError); 517 RunF32x4UnOpTest(kExprF32x4RecipSqrtApprox, RecipSqrt, kApproxError);
532 } 518 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 WASM_EXEC_COMPILED_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); } 550 WASM_EXEC_COMPILED_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); }
565 WASM_EXEC_COMPILED_TEST(F32x4_Min) { 551 WASM_EXEC_COMPILED_TEST(F32x4_Min) {
566 RunF32x4BinOpTest(kExprF32x4Min, Minimum); 552 RunF32x4BinOpTest(kExprF32x4Min, Minimum);
567 } 553 }
568 WASM_EXEC_COMPILED_TEST(F32x4_Max) { 554 WASM_EXEC_COMPILED_TEST(F32x4_Max) {
569 RunF32x4BinOpTest(kExprF32x4Max, Maximum); 555 RunF32x4BinOpTest(kExprF32x4Max, Maximum);
570 } 556 }
571 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || 557 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS ||
572 // V8_TARGET_ARCH_MIPS64 558 // V8_TARGET_ARCH_MIPS64
573 559
574 #if SIMD_LOWERING_TARGET
575 WASM_EXEC_COMPILED_TEST(F32x4Div) { RunF32x4BinOpTest(kExprF32x4Div, Div); }
576 #endif // SIMD_LOWERING_TARGET
577
578 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
579 WASM_EXEC_COMPILED_TEST(F32x4RecipRefine) {
580 RunF32x4BinOpTest(kExprF32x4RecipRefine, RecipRefine);
581 }
582
583 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtRefine) {
584 RunF32x4BinOpTest(kExprF32x4RecipSqrtRefine, RecipSqrtRefine);
585 }
586 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
587
588 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ 560 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
589 V8_TARGET_ARCH_MIPS64 561 V8_TARGET_ARCH_MIPS64
590 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { 562 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) {
591 FLAG_wasm_simd_prototype = true; 563 FLAG_wasm_simd_prototype = true;
592 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); 564 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled);
593 byte a = 0; 565 byte a = 0;
594 byte b = 1; 566 byte b = 1;
595 byte expected = 2; 567 byte expected = 2;
596 byte simd0 = r.AllocateLocal(kWasmS128); 568 byte simd0 = r.AllocateLocal(kWasmS128);
597 byte simd1 = r.AllocateLocal(kWasmS128); 569 byte simd1 = r.AllocateLocal(kWasmS128);
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 WASM_SIMD_I32x4_EXTRACT_LANE( 1985 WASM_SIMD_I32x4_EXTRACT_LANE(
2014 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); 1986 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO)));
2015 1987
2016 FOR_INT32_INPUTS(i) { 1988 FOR_INT32_INPUTS(i) {
2017 int32_t expected = *i; 1989 int32_t expected = *i;
2018 r.module().WriteMemory(&memory[0], expected); 1990 r.module().WriteMemory(&memory[0], expected);
2019 CHECK_EQ(expected, r.Call()); 1991 CHECK_EQ(expected, r.Call());
2020 } 1992 }
2021 } 1993 }
2022 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 1994 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698