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

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

Issue 2721223003: Revert of [wasm]implement simd lowering for simple F32x4 and I32x4 unops (Closed)
Patch Set: Created 3 years, 9 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/compiler/wasm-compiler.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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 template <typename T> 205 template <typename T>
206 T Xor(T a, T b) { 206 T Xor(T a, T b) {
207 return a ^ b; 207 return a ^ b;
208 } 208 }
209 209
210 template <typename T> 210 template <typename T>
211 T Not(T a) { 211 T Not(T a) {
212 return ~a; 212 return ~a;
213 } 213 }
214 214
215 template <typename T>
216 T Sqrt(T a) {
217 return std::sqrt(a);
218 }
219
220 } // namespace 215 } // namespace
221 216
222 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64 217 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64
223 #define SIMD_LOWERING_TARGET 1 218 #define SIMD_LOWERING_TARGET 1
224 #else 219 #else
225 #define SIMD_LOWERING_TARGET 0 220 #define SIMD_LOWERING_TARGET 0
226 #endif // !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64 221 #endif // !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64
227 222
228 // TODO(gdeepti): These are tests using sample values to verify functional 223 // TODO(gdeepti): These are tests using sample values to verify functional
229 // correctness of opcodes, add more tests for a range of values and macroize 224 // correctness of opcodes, add more tests for a range of values and macroize
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 WASM_SIMD_F32x4_REPLACE_LANE(2, WASM_GET_LOCAL(simd), 372 WASM_SIMD_F32x4_REPLACE_LANE(2, WASM_GET_LOCAL(simd),
378 WASM_GET_LOCAL(new_val))), 373 WASM_GET_LOCAL(new_val))),
379 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, new_val, new_val, old_val), 374 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, new_val, new_val, old_val),
380 WASM_SET_LOCAL(simd, 375 WASM_SET_LOCAL(simd,
381 WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), 376 WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd),
382 WASM_GET_LOCAL(new_val))), 377 WASM_GET_LOCAL(new_val))),
383 WASM_SIMD_CHECK_SPLAT4(F32x4, simd, F32, new_val), WASM_ONE); 378 WASM_SIMD_CHECK_SPLAT4(F32x4, simd, F32, new_val), WASM_ONE);
384 379
385 CHECK_EQ(1, r.Call(3.14159f, -1.5f)); 380 CHECK_EQ(1, r.Call(3.14159f, -1.5f));
386 } 381 }
382 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
387 383
384 #if V8_TARGET_ARCH_ARM
388 // Tests both signed and unsigned conversion. 385 // Tests both signed and unsigned conversion.
389 WASM_EXEC_COMPILED_TEST(F32x4FromInt32x4) { 386 WASM_EXEC_COMPILED_TEST(F32x4FromInt32x4) {
390 FLAG_wasm_simd_prototype = true; 387 FLAG_wasm_simd_prototype = true;
391 WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled); 388 WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled);
392 byte a = 0; 389 byte a = 0;
393 byte expected_signed = 1; 390 byte expected_signed = 1;
394 byte expected_unsigned = 2; 391 byte expected_unsigned = 2;
395 byte simd0 = r.AllocateLocal(kWasmS128); 392 byte simd0 = r.AllocateLocal(kWasmS128);
396 byte simd1 = r.AllocateLocal(kWasmS128); 393 byte simd1 = r.AllocateLocal(kWasmS128);
397 byte simd2 = r.AllocateLocal(kWasmS128); 394 byte simd2 = r.AllocateLocal(kWasmS128);
(...skipping 15 matching lines...) Expand all
413 WasmRunner<int32_t, float, float> r(kExecuteCompiled); 410 WasmRunner<int32_t, float, float> r(kExecuteCompiled);
414 byte a = 0; 411 byte a = 0;
415 byte expected = 1; 412 byte expected = 1;
416 byte simd = r.AllocateLocal(kWasmS128); 413 byte simd = r.AllocateLocal(kWasmS128);
417 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), 414 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
418 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 415 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
419 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), WASM_ONE); 416 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), WASM_ONE);
420 417
421 FOR_FLOAT32_INPUTS(i) { 418 FOR_FLOAT32_INPUTS(i) {
422 if (std::isnan(*i)) continue; 419 if (std::isnan(*i)) continue;
423 if (std::isnan(expected_op(*i))) continue;
424 CHECK_EQ(1, r.Call(*i, expected_op(*i))); 420 CHECK_EQ(1, r.Call(*i, expected_op(*i)));
425 } 421 }
426 } 422 }
427 423
428 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } 424 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); }
429 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } 425 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); }
430 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 426 #endif // V8_TARGET_ARCH_ARM
431
432 #if SIMD_LOWERING_TARGET
433 WASM_EXEC_COMPILED_TEST(F32x4Sqrt) { RunF32x4UnOpTest(kExprF32x4Sqrt, Sqrt); }
434 #endif // SIMD_LOWERING_TARGET
435 427
436 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 428 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
437 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op, 429 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op,
438 bool skip_zero_inputs = false) { 430 bool skip_zero_inputs = false) {
439 FLAG_wasm_simd_prototype = true; 431 FLAG_wasm_simd_prototype = true;
440 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); 432 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled);
441 byte a = 0; 433 byte a = 0;
442 byte b = 1; 434 byte b = 1;
443 byte expected = 2; 435 byte expected = 2;
444 byte simd0 = r.AllocateLocal(kWasmS128); 436 byte simd0 = r.AllocateLocal(kWasmS128);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected_signed), 801 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected_signed),
810 WASM_SET_LOCAL(simd2, WASM_SIMD_U32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))), 802 WASM_SET_LOCAL(simd2, WASM_SIMD_U32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))),
811 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE); 803 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE);
812 804
813 FOR_FLOAT32_INPUTS(i) { 805 FOR_FLOAT32_INPUTS(i) {
814 int32_t signed_value = ConvertToInt(*i, false); 806 int32_t signed_value = ConvertToInt(*i, false);
815 int32_t unsigned_value = ConvertToInt(*i, true); 807 int32_t unsigned_value = ConvertToInt(*i, true);
816 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); 808 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value));
817 } 809 }
818 } 810 }
819 #endif // V8_TARGET_ARCH_ARM
820 811
821 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
822 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { 812 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) {
823 FLAG_wasm_simd_prototype = true; 813 FLAG_wasm_simd_prototype = true;
824 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 814 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
825 byte a = 0; 815 byte a = 0;
826 byte expected = 1; 816 byte expected = 1;
827 byte simd = r.AllocateLocal(kWasmS128); 817 byte simd = r.AllocateLocal(kWasmS128);
828 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 818 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
829 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 819 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
830 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); 820 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
831 821
832 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } 822 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
833 } 823 }
834 824
835 WASM_EXEC_COMPILED_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); } 825 WASM_EXEC_COMPILED_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); }
836 826
837 WASM_EXEC_COMPILED_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); } 827 WASM_EXEC_COMPILED_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); }
838 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 828 #endif // V8_TARGET_ARCH_ARM
839 829
840 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { 830 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
841 FLAG_wasm_simd_prototype = true; 831 FLAG_wasm_simd_prototype = true;
842 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 832 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
843 byte a = 0; 833 byte a = 0;
844 byte b = 1; 834 byte b = 1;
845 byte expected = 2; 835 byte expected = 2;
846 byte simd0 = r.AllocateLocal(kWasmS128); 836 byte simd0 = r.AllocateLocal(kWasmS128);
847 byte simd1 = r.AllocateLocal(kWasmS128); 837 byte simd1 = r.AllocateLocal(kWasmS128);
848 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 838 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0), 1551 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0),
1562 WASM_F32(65.0))), 1552 WASM_F32(65.0))),
1563 WASM_I32V(1)); 1553 WASM_I32V(1));
1564 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } 1554 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
1565 CHECK_EQ(*global, 13.5); 1555 CHECK_EQ(*global, 13.5);
1566 CHECK_EQ(*(global + 1), 45.5); 1556 CHECK_EQ(*(global + 1), 45.5);
1567 CHECK_EQ(*(global + 2), 32.25); 1557 CHECK_EQ(*(global + 2), 32.25);
1568 CHECK_EQ(*(global + 3), 65.0); 1558 CHECK_EQ(*(global + 3), 65.0);
1569 } 1559 }
1570 #endif // SIMD_LOWERING_TARGET 1560 #endif // SIMD_LOWERING_TARGET
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698