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

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

Issue 2723943003: Revert of [wasm]implement simd lowering for f32x4->i32x4, i32x4 min/max and shift instructions (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/simd-scalar-lowering.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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, 745 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val,
746 new_val, new_val, new_val, new_val, new_val, new_val, 746 new_val, new_val, new_val, new_val, new_val, new_val,
747 new_val, new_val, new_val, new_val, new_val, old_val), 747 new_val, new_val, new_val, new_val, new_val, old_val),
748 WASM_SET_LOCAL(simd, 748 WASM_SET_LOCAL(simd,
749 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), 749 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd),
750 WASM_GET_LOCAL(new_val))), 750 WASM_GET_LOCAL(new_val))),
751 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); 751 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE);
752 752
753 CHECK_EQ(1, r.Call(1, 2)); 753 CHECK_EQ(1, r.Call(1, 2));
754 } 754 }
755 #endif // V8_TARGET_ARCH_ARM
756 755
757 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
758 // Determines if conversion from float to int will be valid. 756 // Determines if conversion from float to int will be valid.
759 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { 757 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) {
760 const double max_uint = static_cast<double>(0xffffffffu); 758 const double max_uint = static_cast<double>(0xffffffffu);
761 const double max_int = static_cast<double>(kMaxInt); 759 const double max_int = static_cast<double>(kMaxInt);
762 const double min_int = static_cast<double>(kMinInt); 760 const double min_int = static_cast<double>(kMinInt);
763 761
764 // Check for NaN. 762 // Check for NaN.
765 if (val != val) { 763 if (val != val) {
766 return false; 764 return false;
767 } 765 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected_signed), 809 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected_signed),
812 WASM_SET_LOCAL(simd2, WASM_SIMD_U32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))), 810 WASM_SET_LOCAL(simd2, WASM_SIMD_U32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))),
813 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE); 811 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE);
814 812
815 FOR_FLOAT32_INPUTS(i) { 813 FOR_FLOAT32_INPUTS(i) {
816 int32_t signed_value = ConvertToInt(*i, false); 814 int32_t signed_value = ConvertToInt(*i, false);
817 int32_t unsigned_value = ConvertToInt(*i, true); 815 int32_t unsigned_value = ConvertToInt(*i, true);
818 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); 816 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value));
819 } 817 }
820 } 818 }
819 #endif // V8_TARGET_ARCH_ARM
821 820
821 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
822 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { 822 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) {
823 FLAG_wasm_simd_prototype = true; 823 FLAG_wasm_simd_prototype = true;
824 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 824 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
825 byte a = 0; 825 byte a = 0;
826 byte expected = 1; 826 byte expected = 1;
827 byte simd = r.AllocateLocal(kWasmS128); 827 byte simd = r.AllocateLocal(kWasmS128);
828 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 828 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))), 829 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
830 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); 830 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
831 831
(...skipping 29 matching lines...) Expand all
861 WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } 861 WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); }
862 862
863 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 863 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
864 WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); } 864 WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); }
865 865
866 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } 866 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); }
867 867
868 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } 868 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); }
869 869
870 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } 870 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); }
871 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
871 872
873 #if V8_TARGET_ARCH_ARM
872 WASM_EXEC_COMPILED_TEST(I32x4Min) { 874 WASM_EXEC_COMPILED_TEST(I32x4Min) {
873 RunI32x4BinOpTest(kExprI32x4MinS, Minimum); 875 RunI32x4BinOpTest(kExprI32x4MinS, Minimum);
874 } 876 }
875 877
876 WASM_EXEC_COMPILED_TEST(I32x4Max) { 878 WASM_EXEC_COMPILED_TEST(I32x4Max) {
877 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); 879 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum);
878 } 880 }
879 881
880 WASM_EXEC_COMPILED_TEST(Ui32x4Min) { 882 WASM_EXEC_COMPILED_TEST(Ui32x4Min) {
881 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); 883 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum);
882 } 884 }
883 885
884 WASM_EXEC_COMPILED_TEST(Ui32x4Max) { 886 WASM_EXEC_COMPILED_TEST(Ui32x4Max) {
885 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); 887 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum);
886 } 888 }
887 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
888 889
889 #if V8_TARGET_ARCH_ARM 890
891
890 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { 892 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
891 FLAG_wasm_simd_prototype = true; 893 FLAG_wasm_simd_prototype = true;
892 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 894 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
893 byte a = 0; 895 byte a = 0;
894 byte b = 1; 896 byte b = 1;
895 byte expected = 2; 897 byte expected = 2;
896 byte simd0 = r.AllocateLocal(kWasmS128); 898 byte simd0 = r.AllocateLocal(kWasmS128);
897 byte simd1 = r.AllocateLocal(kWasmS128); 899 byte simd1 = r.AllocateLocal(kWasmS128);
898 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 900 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
899 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), 901 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); 942 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual);
941 } 943 }
942 944
943 WASM_EXEC_COMPILED_TEST(Ui32x4Less) { 945 WASM_EXEC_COMPILED_TEST(Ui32x4Less) {
944 RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); 946 RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess);
945 } 947 }
946 948
947 WASM_EXEC_COMPILED_TEST(Ui32x4LessEqual) { 949 WASM_EXEC_COMPILED_TEST(Ui32x4LessEqual) {
948 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); 950 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual);
949 } 951 }
950 #endif // V8_TARGET_ARCH_ARM
951 952
952 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
953 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, 953 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op,
954 int shift) { 954 int shift) {
955 FLAG_wasm_simd_prototype = true; 955 FLAG_wasm_simd_prototype = true;
956 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 956 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
957 byte a = 0; 957 byte a = 0;
958 byte expected = 1; 958 byte expected = 1;
959 byte simd = r.AllocateLocal(kWasmS128); 959 byte simd = r.AllocateLocal(kWasmS128);
960 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 960 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
961 WASM_SET_LOCAL( 961 WASM_SET_LOCAL(
962 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), 962 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
963 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); 963 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
964 964
965 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } 965 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
966 } 966 }
967 967
968 WASM_EXEC_COMPILED_TEST(I32x4Shl) { 968 WASM_EXEC_COMPILED_TEST(I32x4Shl) {
969 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); 969 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1);
970 } 970 }
971 971
972 WASM_EXEC_COMPILED_TEST(I32x4ShrS) { 972 WASM_EXEC_COMPILED_TEST(I32x4ShrS) {
973 RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); 973 RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1);
974 } 974 }
975 975
976 WASM_EXEC_COMPILED_TEST(I32x4ShrU) { 976 WASM_EXEC_COMPILED_TEST(I32x4ShrU) {
977 RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1); 977 RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1);
978 } 978 }
979 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
980
981 #if V8_TARGET_ARCH_ARM
982 979
983 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { 980 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) {
984 FLAG_wasm_simd_prototype = true; 981 FLAG_wasm_simd_prototype = true;
985 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 982 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
986 byte a = 0; 983 byte a = 0;
987 byte expected = 1; 984 byte expected = 1;
988 byte simd = r.AllocateLocal(kWasmS128); 985 byte simd = r.AllocateLocal(kWasmS128);
989 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), 986 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
990 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 987 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
991 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); 988 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE);
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0), 1561 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0),
1565 WASM_F32(65.0))), 1562 WASM_F32(65.0))),
1566 WASM_I32V(1)); 1563 WASM_I32V(1));
1567 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } 1564 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
1568 CHECK_EQ(*global, 13.5); 1565 CHECK_EQ(*global, 13.5);
1569 CHECK_EQ(*(global + 1), 45.5); 1566 CHECK_EQ(*(global + 1), 45.5);
1570 CHECK_EQ(*(global + 2), 32.25); 1567 CHECK_EQ(*(global + 2), 32.25);
1571 CHECK_EQ(*(global + 3), 65.0); 1568 CHECK_EQ(*(global + 3), 65.0);
1572 } 1569 }
1573 #endif // SIMD_LOWERING_TARGET 1570 #endif // SIMD_LOWERING_TARGET
OLDNEW
« no previous file with comments | « src/compiler/simd-scalar-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698