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

Side by Side Diff: test/cctest/test-assembler-x64.cc

Issue 757503002: [x64] Introduce FMA3 instructions on scalar data elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove avx_os_support Created 6 years 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/x64/disasm-x64.cc ('k') | test/cctest/test-disasm-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 Code::ComputeFlags(Code::STUB), 729 Code::ComputeFlags(Code::STUB),
730 Handle<Code>()); 730 Handle<Code>());
731 #ifdef OBJECT_PRINT 731 #ifdef OBJECT_PRINT
732 OFStream os(stdout); 732 OFStream os(stdout);
733 code->Print(os); 733 code->Print(os);
734 #endif 734 #endif
735 735
736 F6 f = FUNCTION_CAST<F6>(code->entry()); 736 F6 f = FUNCTION_CAST<F6>(code->entry());
737 CHECK_EQ(2, f(1.0, 2.0)); 737 CHECK_EQ(2, f(1.0, 2.0));
738 } 738 }
739
740
741 typedef int (*F7)(double x, double y, double z);
742 TEST(AssemblerX64FMA_sd) {
743 CcTest::InitializeVM();
744 if (!CpuFeatures::IsSupported(FMA3)) return;
745
746 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
747 HandleScope scope(isolate);
748 v8::internal::byte buffer[1024];
749 MacroAssembler assm(isolate, buffer, sizeof buffer);
750 {
751 CpuFeatureScope fscope(&assm, FMA3);
752 Label exit;
753 // argument in xmm0, xmm1 and xmm2
754 // xmm0 * xmm1 + xmm2
755 __ movaps(xmm3, xmm0);
756 __ mulsd(xmm3, xmm1);
757 __ addsd(xmm3, xmm2); // Expected result in xmm3
758
759 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand
760 // vfmadd132sd
761 __ movl(rax, Immediate(1)); // Test number
762 __ movaps(xmm8, xmm0);
763 __ vfmadd132sd(xmm8, xmm2, xmm1);
764 __ ucomisd(xmm8, xmm3);
765 __ j(not_equal, &exit);
766 // vfmadd213sd
767 __ incq(rax);
768 __ movaps(xmm8, xmm1);
769 __ vfmadd213sd(xmm8, xmm0, xmm2);
770 __ ucomisd(xmm8, xmm3);
771 __ j(not_equal, &exit);
772 // vfmadd231sd
773 __ incq(rax);
774 __ movaps(xmm8, xmm2);
775 __ vfmadd231sd(xmm8, xmm0, xmm1);
776 __ ucomisd(xmm8, xmm3);
777 __ j(not_equal, &exit);
778
779 // vfmadd132sd
780 __ incq(rax);
781 __ movaps(xmm8, xmm0);
782 __ movsd(Operand(rsp, 0), xmm1);
783 __ vfmadd132sd(xmm8, xmm2, Operand(rsp, 0));
784 __ ucomisd(xmm8, xmm3);
785 __ j(not_equal, &exit);
786 // vfmadd213sd
787 __ incq(rax);
788 __ movaps(xmm8, xmm1);
789 __ movsd(Operand(rsp, 0), xmm2);
790 __ vfmadd213sd(xmm8, xmm0, Operand(rsp, 0));
791 __ ucomisd(xmm8, xmm3);
792 __ j(not_equal, &exit);
793 // vfmadd231sd
794 __ incq(rax);
795 __ movaps(xmm8, xmm2);
796 __ movsd(Operand(rsp, 0), xmm1);
797 __ vfmadd231sd(xmm8, xmm0, Operand(rsp, 0));
798 __ ucomisd(xmm8, xmm3);
799 __ j(not_equal, &exit);
800
801 // xmm0 * xmm1 - xmm2
802 __ movaps(xmm3, xmm0);
803 __ mulsd(xmm3, xmm1);
804 __ subsd(xmm3, xmm2); // Expected result in xmm3
805
806 // vfmsub132sd
807 __ incq(rax);
808 __ movaps(xmm8, xmm0);
809 __ vfmsub132sd(xmm8, xmm2, xmm1);
810 __ ucomisd(xmm8, xmm3);
811 __ j(not_equal, &exit);
812 // vfmadd213sd
813 __ incq(rax);
814 __ movaps(xmm8, xmm1);
815 __ vfmsub213sd(xmm8, xmm0, xmm2);
816 __ ucomisd(xmm8, xmm3);
817 __ j(not_equal, &exit);
818 // vfmsub231sd
819 __ incq(rax);
820 __ movaps(xmm8, xmm2);
821 __ vfmsub231sd(xmm8, xmm0, xmm1);
822 __ ucomisd(xmm8, xmm3);
823 __ j(not_equal, &exit);
824
825 // vfmsub132sd
826 __ incq(rax);
827 __ movaps(xmm8, xmm0);
828 __ movsd(Operand(rsp, 0), xmm1);
829 __ vfmsub132sd(xmm8, xmm2, Operand(rsp, 0));
830 __ ucomisd(xmm8, xmm3);
831 __ j(not_equal, &exit);
832 // vfmsub213sd
833 __ incq(rax);
834 __ movaps(xmm8, xmm1);
835 __ movsd(Operand(rsp, 0), xmm2);
836 __ vfmsub213sd(xmm8, xmm0, Operand(rsp, 0));
837 __ ucomisd(xmm8, xmm3);
838 __ j(not_equal, &exit);
839 // vfmsub231sd
840 __ incq(rax);
841 __ movaps(xmm8, xmm2);
842 __ movsd(Operand(rsp, 0), xmm1);
843 __ vfmsub231sd(xmm8, xmm0, Operand(rsp, 0));
844 __ ucomisd(xmm8, xmm3);
845 __ j(not_equal, &exit);
846
847
848 // - xmm0 * xmm1 + xmm2
849 __ movaps(xmm3, xmm0);
850 __ mulsd(xmm3, xmm1);
851 __ Move(xmm4, (uint64_t)1 << 63);
852 __ xorpd(xmm3, xmm4);
853 __ addsd(xmm3, xmm2); // Expected result in xmm3
854
855 // vfnmadd132sd
856 __ incq(rax);
857 __ movaps(xmm8, xmm0);
858 __ vfnmadd132sd(xmm8, xmm2, xmm1);
859 __ ucomisd(xmm8, xmm3);
860 __ j(not_equal, &exit);
861 // vfmadd213sd
862 __ incq(rax);
863 __ movaps(xmm8, xmm1);
864 __ vfnmadd213sd(xmm8, xmm0, xmm2);
865 __ ucomisd(xmm8, xmm3);
866 __ j(not_equal, &exit);
867 // vfnmadd231sd
868 __ incq(rax);
869 __ movaps(xmm8, xmm2);
870 __ vfnmadd231sd(xmm8, xmm0, xmm1);
871 __ ucomisd(xmm8, xmm3);
872 __ j(not_equal, &exit);
873
874 // vfnmadd132sd
875 __ incq(rax);
876 __ movaps(xmm8, xmm0);
877 __ movsd(Operand(rsp, 0), xmm1);
878 __ vfnmadd132sd(xmm8, xmm2, Operand(rsp, 0));
879 __ ucomisd(xmm8, xmm3);
880 __ j(not_equal, &exit);
881 // vfnmadd213sd
882 __ incq(rax);
883 __ movaps(xmm8, xmm1);
884 __ movsd(Operand(rsp, 0), xmm2);
885 __ vfnmadd213sd(xmm8, xmm0, Operand(rsp, 0));
886 __ ucomisd(xmm8, xmm3);
887 __ j(not_equal, &exit);
888 // vfnmadd231sd
889 __ incq(rax);
890 __ movaps(xmm8, xmm2);
891 __ movsd(Operand(rsp, 0), xmm1);
892 __ vfnmadd231sd(xmm8, xmm0, Operand(rsp, 0));
893 __ ucomisd(xmm8, xmm3);
894 __ j(not_equal, &exit);
895
896
897 // - xmm0 * xmm1 - xmm2
898 __ movaps(xmm3, xmm0);
899 __ mulsd(xmm3, xmm1);
900 __ Move(xmm4, (uint64_t)1 << 63);
901 __ xorpd(xmm3, xmm4);
902 __ subsd(xmm3, xmm2); // Expected result in xmm3
903
904 // vfnmsub132sd
905 __ incq(rax);
906 __ movaps(xmm8, xmm0);
907 __ vfnmsub132sd(xmm8, xmm2, xmm1);
908 __ ucomisd(xmm8, xmm3);
909 __ j(not_equal, &exit);
910 // vfmsub213sd
911 __ incq(rax);
912 __ movaps(xmm8, xmm1);
913 __ vfnmsub213sd(xmm8, xmm0, xmm2);
914 __ ucomisd(xmm8, xmm3);
915 __ j(not_equal, &exit);
916 // vfnmsub231sd
917 __ incq(rax);
918 __ movaps(xmm8, xmm2);
919 __ vfnmsub231sd(xmm8, xmm0, xmm1);
920 __ ucomisd(xmm8, xmm3);
921 __ j(not_equal, &exit);
922
923 // vfnmsub132sd
924 __ incq(rax);
925 __ movaps(xmm8, xmm0);
926 __ movsd(Operand(rsp, 0), xmm1);
927 __ vfnmsub132sd(xmm8, xmm2, Operand(rsp, 0));
928 __ ucomisd(xmm8, xmm3);
929 __ j(not_equal, &exit);
930 // vfnmsub213sd
931 __ incq(rax);
932 __ movaps(xmm8, xmm1);
933 __ movsd(Operand(rsp, 0), xmm2);
934 __ vfnmsub213sd(xmm8, xmm0, Operand(rsp, 0));
935 __ ucomisd(xmm8, xmm3);
936 __ j(not_equal, &exit);
937 // vfnmsub231sd
938 __ incq(rax);
939 __ movaps(xmm8, xmm2);
940 __ movsd(Operand(rsp, 0), xmm1);
941 __ vfnmsub231sd(xmm8, xmm0, Operand(rsp, 0));
942 __ ucomisd(xmm8, xmm3);
943 __ j(not_equal, &exit);
944
945
946 __ xorl(rax, rax);
947 __ bind(&exit);
948 __ addq(rsp, Immediate(kDoubleSize));
949 __ ret(0);
950 }
951
952 CodeDesc desc;
953 assm.GetCode(&desc);
954 Handle<Code> code = isolate->factory()->NewCode(
955 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
956 #ifdef OBJECT_PRINT
957 OFStream os(stdout);
958 code->Print(os);
959 #endif
960
961 F7 f = FUNCTION_CAST<F7>(code->entry());
962 CHECK_EQ(0, f(0.000092662107262076, -2.460774966188315, -1.0958787393627414));
963 }
964
965
966 typedef int (*F8)(float x, float y, float z);
967 TEST(AssemblerX64FMA_ss) {
968 CcTest::InitializeVM();
969 if (!CpuFeatures::IsSupported(FMA3)) return;
970
971 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
972 HandleScope scope(isolate);
973 v8::internal::byte buffer[1024];
974 MacroAssembler assm(isolate, buffer, sizeof buffer);
975 {
976 CpuFeatureScope fscope(&assm, FMA3);
977 Label exit;
978 // arguments in xmm0, xmm1 and xmm2
979 // xmm0 * xmm1 + xmm2
980 __ movaps(xmm3, xmm0);
981 __ mulss(xmm3, xmm1);
982 __ addss(xmm3, xmm2); // Expected result in xmm3
983
984 __ subq(rsp, Immediate(kDoubleSize)); // For memory operand
985 // vfmadd132ss
986 __ movl(rax, Immediate(1)); // Test number
987 __ movaps(xmm8, xmm0);
988 __ vfmadd132ss(xmm8, xmm2, xmm1);
989 __ ucomiss(xmm8, xmm3);
990 __ j(not_equal, &exit);
991 // vfmadd213ss
992 __ incq(rax);
993 __ movaps(xmm8, xmm1);
994 __ vfmadd213ss(xmm8, xmm0, xmm2);
995 __ ucomiss(xmm8, xmm3);
996 __ j(not_equal, &exit);
997 // vfmadd231ss
998 __ incq(rax);
999 __ movaps(xmm8, xmm2);
1000 __ vfmadd231ss(xmm8, xmm0, xmm1);
1001 __ ucomiss(xmm8, xmm3);
1002 __ j(not_equal, &exit);
1003
1004 // vfmadd132ss
1005 __ incq(rax);
1006 __ movaps(xmm8, xmm0);
1007 __ movss(Operand(rsp, 0), xmm1);
1008 __ vfmadd132ss(xmm8, xmm2, Operand(rsp, 0));
1009 __ ucomiss(xmm8, xmm3);
1010 __ j(not_equal, &exit);
1011 // vfmadd213ss
1012 __ incq(rax);
1013 __ movaps(xmm8, xmm1);
1014 __ movss(Operand(rsp, 0), xmm2);
1015 __ vfmadd213ss(xmm8, xmm0, Operand(rsp, 0));
1016 __ ucomiss(xmm8, xmm3);
1017 __ j(not_equal, &exit);
1018 // vfmadd231ss
1019 __ incq(rax);
1020 __ movaps(xmm8, xmm2);
1021 __ movss(Operand(rsp, 0), xmm1);
1022 __ vfmadd231ss(xmm8, xmm0, Operand(rsp, 0));
1023 __ ucomiss(xmm8, xmm3);
1024 __ j(not_equal, &exit);
1025
1026 // xmm0 * xmm1 - xmm2
1027 __ movaps(xmm3, xmm0);
1028 __ mulss(xmm3, xmm1);
1029 __ subss(xmm3, xmm2); // Expected result in xmm3
1030
1031 // vfmsub132ss
1032 __ incq(rax);
1033 __ movaps(xmm8, xmm0);
1034 __ vfmsub132ss(xmm8, xmm2, xmm1);
1035 __ ucomiss(xmm8, xmm3);
1036 __ j(not_equal, &exit);
1037 // vfmadd213ss
1038 __ incq(rax);
1039 __ movaps(xmm8, xmm1);
1040 __ vfmsub213ss(xmm8, xmm0, xmm2);
1041 __ ucomiss(xmm8, xmm3);
1042 __ j(not_equal, &exit);
1043 // vfmsub231ss
1044 __ incq(rax);
1045 __ movaps(xmm8, xmm2);
1046 __ vfmsub231ss(xmm8, xmm0, xmm1);
1047 __ ucomiss(xmm8, xmm3);
1048 __ j(not_equal, &exit);
1049
1050 // vfmsub132ss
1051 __ incq(rax);
1052 __ movaps(xmm8, xmm0);
1053 __ movss(Operand(rsp, 0), xmm1);
1054 __ vfmsub132ss(xmm8, xmm2, Operand(rsp, 0));
1055 __ ucomiss(xmm8, xmm3);
1056 __ j(not_equal, &exit);
1057 // vfmsub213ss
1058 __ incq(rax);
1059 __ movaps(xmm8, xmm1);
1060 __ movss(Operand(rsp, 0), xmm2);
1061 __ vfmsub213ss(xmm8, xmm0, Operand(rsp, 0));
1062 __ ucomiss(xmm8, xmm3);
1063 __ j(not_equal, &exit);
1064 // vfmsub231ss
1065 __ incq(rax);
1066 __ movaps(xmm8, xmm2);
1067 __ movss(Operand(rsp, 0), xmm1);
1068 __ vfmsub231ss(xmm8, xmm0, Operand(rsp, 0));
1069 __ ucomiss(xmm8, xmm3);
1070 __ j(not_equal, &exit);
1071
1072
1073 // - xmm0 * xmm1 + xmm2
1074 __ movaps(xmm3, xmm0);
1075 __ mulss(xmm3, xmm1);
1076 __ Move(xmm4, (uint32_t)1 << 31);
1077 __ xorps(xmm3, xmm4);
1078 __ addss(xmm3, xmm2); // Expected result in xmm3
1079
1080 // vfnmadd132ss
1081 __ incq(rax);
1082 __ movaps(xmm8, xmm0);
1083 __ vfnmadd132ss(xmm8, xmm2, xmm1);
1084 __ ucomiss(xmm8, xmm3);
1085 __ j(not_equal, &exit);
1086 // vfmadd213ss
1087 __ incq(rax);
1088 __ movaps(xmm8, xmm1);
1089 __ vfnmadd213ss(xmm8, xmm0, xmm2);
1090 __ ucomiss(xmm8, xmm3);
1091 __ j(not_equal, &exit);
1092 // vfnmadd231ss
1093 __ incq(rax);
1094 __ movaps(xmm8, xmm2);
1095 __ vfnmadd231ss(xmm8, xmm0, xmm1);
1096 __ ucomiss(xmm8, xmm3);
1097 __ j(not_equal, &exit);
1098
1099 // vfnmadd132ss
1100 __ incq(rax);
1101 __ movaps(xmm8, xmm0);
1102 __ movss(Operand(rsp, 0), xmm1);
1103 __ vfnmadd132ss(xmm8, xmm2, Operand(rsp, 0));
1104 __ ucomiss(xmm8, xmm3);
1105 __ j(not_equal, &exit);
1106 // vfnmadd213ss
1107 __ incq(rax);
1108 __ movaps(xmm8, xmm1);
1109 __ movss(Operand(rsp, 0), xmm2);
1110 __ vfnmadd213ss(xmm8, xmm0, Operand(rsp, 0));
1111 __ ucomiss(xmm8, xmm3);
1112 __ j(not_equal, &exit);
1113 // vfnmadd231ss
1114 __ incq(rax);
1115 __ movaps(xmm8, xmm2);
1116 __ movss(Operand(rsp, 0), xmm1);
1117 __ vfnmadd231ss(xmm8, xmm0, Operand(rsp, 0));
1118 __ ucomiss(xmm8, xmm3);
1119 __ j(not_equal, &exit);
1120
1121
1122 // - xmm0 * xmm1 - xmm2
1123 __ movaps(xmm3, xmm0);
1124 __ mulss(xmm3, xmm1);
1125 __ Move(xmm4, (uint32_t)1 << 31);
1126 __ xorps(xmm3, xmm4);
1127 __ subss(xmm3, xmm2); // Expected result in xmm3
1128
1129 // vfnmsub132ss
1130 __ incq(rax);
1131 __ movaps(xmm8, xmm0);
1132 __ vfnmsub132ss(xmm8, xmm2, xmm1);
1133 __ ucomiss(xmm8, xmm3);
1134 __ j(not_equal, &exit);
1135 // vfmsub213ss
1136 __ incq(rax);
1137 __ movaps(xmm8, xmm1);
1138 __ vfnmsub213ss(xmm8, xmm0, xmm2);
1139 __ ucomiss(xmm8, xmm3);
1140 __ j(not_equal, &exit);
1141 // vfnmsub231ss
1142 __ incq(rax);
1143 __ movaps(xmm8, xmm2);
1144 __ vfnmsub231ss(xmm8, xmm0, xmm1);
1145 __ ucomiss(xmm8, xmm3);
1146 __ j(not_equal, &exit);
1147
1148 // vfnmsub132ss
1149 __ incq(rax);
1150 __ movaps(xmm8, xmm0);
1151 __ movss(Operand(rsp, 0), xmm1);
1152 __ vfnmsub132ss(xmm8, xmm2, Operand(rsp, 0));
1153 __ ucomiss(xmm8, xmm3);
1154 __ j(not_equal, &exit);
1155 // vfnmsub213ss
1156 __ incq(rax);
1157 __ movaps(xmm8, xmm1);
1158 __ movss(Operand(rsp, 0), xmm2);
1159 __ vfnmsub213ss(xmm8, xmm0, Operand(rsp, 0));
1160 __ ucomiss(xmm8, xmm3);
1161 __ j(not_equal, &exit);
1162 // vfnmsub231ss
1163 __ incq(rax);
1164 __ movaps(xmm8, xmm2);
1165 __ movss(Operand(rsp, 0), xmm1);
1166 __ vfnmsub231ss(xmm8, xmm0, Operand(rsp, 0));
1167 __ ucomiss(xmm8, xmm3);
1168 __ j(not_equal, &exit);
1169
1170
1171 __ xorl(rax, rax);
1172 __ bind(&exit);
1173 __ addq(rsp, Immediate(kDoubleSize));
1174 __ ret(0);
1175 }
1176
1177 CodeDesc desc;
1178 assm.GetCode(&desc);
1179 Handle<Code> code = isolate->factory()->NewCode(
1180 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1181 #ifdef OBJECT_PRINT
1182 OFStream os(stdout);
1183 code->Print(os);
1184 #endif
1185
1186 F8 f = FUNCTION_CAST<F8>(code->entry());
1187 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f));
1188 }
739 #undef __ 1189 #undef __
OLDNEW
« no previous file with comments | « src/x64/disasm-x64.cc ('k') | test/cctest/test-disasm-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698