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

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

Issue 773783002: [ia32] Introduce FMA3 instructions on scalar data elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/ia32/disasm-ia32.cc ('k') | test/cctest/test-disasm-ia32.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 #ifdef OBJECT_PRINT 582 #ifdef OBJECT_PRINT
583 OFStream os(stdout); 583 OFStream os(stdout);
584 code->Print(os); 584 code->Print(os);
585 #endif 585 #endif
586 586
587 F8 f = FUNCTION_CAST<F8>(code->entry()); 587 F8 f = FUNCTION_CAST<F8>(code->entry());
588 CHECK_EQ(2, f(1.0, 2.0)); 588 CHECK_EQ(2, f(1.0, 2.0));
589 } 589 }
590 590
591 591
592 typedef int (*F9)(double x, double y, double z);
593 TEST(AssemblerX64FMA_sd) {
594 CcTest::InitializeVM();
595 if (!CpuFeatures::IsSupported(FMA3)) return;
596
597 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
598 HandleScope scope(isolate);
599 v8::internal::byte buffer[1024];
600 MacroAssembler assm(isolate, buffer, sizeof buffer);
601 {
602 CpuFeatureScope fscope(&assm, FMA3);
603 Label exit;
604 __ movsd(xmm0, Operand(esp, 1 * kPointerSize));
605 __ movsd(xmm1, Operand(esp, 3 * kPointerSize));
606 __ movsd(xmm2, Operand(esp, 5 * kPointerSize));
607 // argument in xmm0, xmm1 and xmm2
608 // xmm0 * xmm1 + xmm2
609 __ movaps(xmm3, xmm0);
610 __ mulsd(xmm3, xmm1);
611 __ addsd(xmm3, xmm2); // Expected result in xmm3
612
613 __ sub(esp, Immediate(kDoubleSize)); // For memory operand
614 // vfmadd132sd
615 __ mov(eax, Immediate(1)); // Test number
616 __ movaps(xmm4, xmm0);
617 __ vfmadd132sd(xmm4, xmm2, xmm1);
618 __ ucomisd(xmm4, xmm3);
619 __ j(not_equal, &exit);
620 // vfmadd213sd
621 __ inc(eax);
622 __ movaps(xmm4, xmm1);
623 __ vfmadd213sd(xmm4, xmm0, xmm2);
624 __ ucomisd(xmm4, xmm3);
625 __ j(not_equal, &exit);
626 // vfmadd231sd
627 __ inc(eax);
628 __ movaps(xmm4, xmm2);
629 __ vfmadd231sd(xmm4, xmm0, xmm1);
630 __ ucomisd(xmm4, xmm3);
631 __ j(not_equal, &exit);
632
633 // vfmadd132sd
634 __ inc(eax);
635 __ movaps(xmm4, xmm0);
636 __ movsd(Operand(esp, 0), xmm1);
637 __ vfmadd132sd(xmm4, xmm2, Operand(esp, 0));
638 __ ucomisd(xmm4, xmm3);
639 __ j(not_equal, &exit);
640 // vfmadd213sd
641 __ inc(eax);
642 __ movaps(xmm4, xmm1);
643 __ movsd(Operand(esp, 0), xmm2);
644 __ vfmadd213sd(xmm4, xmm0, Operand(esp, 0));
645 __ ucomisd(xmm4, xmm3);
646 __ j(not_equal, &exit);
647 // vfmadd231sd
648 __ inc(eax);
649 __ movaps(xmm4, xmm2);
650 __ movsd(Operand(esp, 0), xmm1);
651 __ vfmadd231sd(xmm4, xmm0, Operand(esp, 0));
652 __ ucomisd(xmm4, xmm3);
653 __ j(not_equal, &exit);
654
655 // xmm0 * xmm1 - xmm2
656 __ movaps(xmm3, xmm0);
657 __ mulsd(xmm3, xmm1);
658 __ subsd(xmm3, xmm2); // Expected result in xmm3
659
660 // vfmsub132sd
661 __ inc(eax);
662 __ movaps(xmm4, xmm0);
663 __ vfmsub132sd(xmm4, xmm2, xmm1);
664 __ ucomisd(xmm4, xmm3);
665 __ j(not_equal, &exit);
666 // vfmadd213sd
667 __ inc(eax);
668 __ movaps(xmm4, xmm1);
669 __ vfmsub213sd(xmm4, xmm0, xmm2);
670 __ ucomisd(xmm4, xmm3);
671 __ j(not_equal, &exit);
672 // vfmsub231sd
673 __ inc(eax);
674 __ movaps(xmm4, xmm2);
675 __ vfmsub231sd(xmm4, xmm0, xmm1);
676 __ ucomisd(xmm4, xmm3);
677 __ j(not_equal, &exit);
678
679 // vfmsub132sd
680 __ inc(eax);
681 __ movaps(xmm4, xmm0);
682 __ movsd(Operand(esp, 0), xmm1);
683 __ vfmsub132sd(xmm4, xmm2, Operand(esp, 0));
684 __ ucomisd(xmm4, xmm3);
685 __ j(not_equal, &exit);
686 // vfmsub213sd
687 __ inc(eax);
688 __ movaps(xmm4, xmm1);
689 __ movsd(Operand(esp, 0), xmm2);
690 __ vfmsub213sd(xmm4, xmm0, Operand(esp, 0));
691 __ ucomisd(xmm4, xmm3);
692 __ j(not_equal, &exit);
693 // vfmsub231sd
694 __ inc(eax);
695 __ movaps(xmm4, xmm2);
696 __ movsd(Operand(esp, 0), xmm1);
697 __ vfmsub231sd(xmm4, xmm0, Operand(esp, 0));
698 __ ucomisd(xmm4, xmm3);
699 __ j(not_equal, &exit);
700
701
702 // - xmm0 * xmm1 + xmm2
703 __ movaps(xmm3, xmm0);
704 __ mulsd(xmm3, xmm1);
705 __ Move(xmm4, (uint64_t)1 << 63);
706 __ xorpd(xmm3, xmm4);
707 __ addsd(xmm3, xmm2); // Expected result in xmm3
708
709 // vfnmadd132sd
710 __ inc(eax);
711 __ movaps(xmm4, xmm0);
712 __ vfnmadd132sd(xmm4, xmm2, xmm1);
713 __ ucomisd(xmm4, xmm3);
714 __ j(not_equal, &exit);
715 // vfmadd213sd
716 __ inc(eax);
717 __ movaps(xmm4, xmm1);
718 __ vfnmadd213sd(xmm4, xmm0, xmm2);
719 __ ucomisd(xmm4, xmm3);
720 __ j(not_equal, &exit);
721 // vfnmadd231sd
722 __ inc(eax);
723 __ movaps(xmm4, xmm2);
724 __ vfnmadd231sd(xmm4, xmm0, xmm1);
725 __ ucomisd(xmm4, xmm3);
726 __ j(not_equal, &exit);
727
728 // vfnmadd132sd
729 __ inc(eax);
730 __ movaps(xmm4, xmm0);
731 __ movsd(Operand(esp, 0), xmm1);
732 __ vfnmadd132sd(xmm4, xmm2, Operand(esp, 0));
733 __ ucomisd(xmm4, xmm3);
734 __ j(not_equal, &exit);
735 // vfnmadd213sd
736 __ inc(eax);
737 __ movaps(xmm4, xmm1);
738 __ movsd(Operand(esp, 0), xmm2);
739 __ vfnmadd213sd(xmm4, xmm0, Operand(esp, 0));
740 __ ucomisd(xmm4, xmm3);
741 __ j(not_equal, &exit);
742 // vfnmadd231sd
743 __ inc(eax);
744 __ movaps(xmm4, xmm2);
745 __ movsd(Operand(esp, 0), xmm1);
746 __ vfnmadd231sd(xmm4, xmm0, Operand(esp, 0));
747 __ ucomisd(xmm4, xmm3);
748 __ j(not_equal, &exit);
749
750
751 // - xmm0 * xmm1 - xmm2
752 __ movaps(xmm3, xmm0);
753 __ mulsd(xmm3, xmm1);
754 __ Move(xmm4, (uint64_t)1 << 63);
755 __ xorpd(xmm3, xmm4);
756 __ subsd(xmm3, xmm2); // Expected result in xmm3
757
758 // vfnmsub132sd
759 __ inc(eax);
760 __ movaps(xmm4, xmm0);
761 __ vfnmsub132sd(xmm4, xmm2, xmm1);
762 __ ucomisd(xmm4, xmm3);
763 __ j(not_equal, &exit);
764 // vfmsub213sd
765 __ inc(eax);
766 __ movaps(xmm4, xmm1);
767 __ vfnmsub213sd(xmm4, xmm0, xmm2);
768 __ ucomisd(xmm4, xmm3);
769 __ j(not_equal, &exit);
770 // vfnmsub231sd
771 __ inc(eax);
772 __ movaps(xmm4, xmm2);
773 __ vfnmsub231sd(xmm4, xmm0, xmm1);
774 __ ucomisd(xmm4, xmm3);
775 __ j(not_equal, &exit);
776
777 // vfnmsub132sd
778 __ inc(eax);
779 __ movaps(xmm4, xmm0);
780 __ movsd(Operand(esp, 0), xmm1);
781 __ vfnmsub132sd(xmm4, xmm2, Operand(esp, 0));
782 __ ucomisd(xmm4, xmm3);
783 __ j(not_equal, &exit);
784 // vfnmsub213sd
785 __ inc(eax);
786 __ movaps(xmm4, xmm1);
787 __ movsd(Operand(esp, 0), xmm2);
788 __ vfnmsub213sd(xmm4, xmm0, Operand(esp, 0));
789 __ ucomisd(xmm4, xmm3);
790 __ j(not_equal, &exit);
791 // vfnmsub231sd
792 __ inc(eax);
793 __ movaps(xmm4, xmm2);
794 __ movsd(Operand(esp, 0), xmm1);
795 __ vfnmsub231sd(xmm4, xmm0, Operand(esp, 0));
796 __ ucomisd(xmm4, xmm3);
797 __ j(not_equal, &exit);
798
799
800 __ xor_(eax, eax);
801 __ bind(&exit);
802 __ add(esp, Immediate(kDoubleSize));
803 __ ret(0);
804 }
805
806 CodeDesc desc;
807 assm.GetCode(&desc);
808 Handle<Code> code = isolate->factory()->NewCode(
809 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
810 #ifdef OBJECT_PRINT
811 OFStream os(stdout);
812 code->Print(os);
813 #endif
814
815 F9 f = FUNCTION_CAST<F9>(code->entry());
816 CHECK_EQ(0, f(0.000092662107262076, -2.460774966188315, -1.0958787393627414));
817 }
818
819
820 typedef int (*F10)(float x, float y, float z);
821 TEST(AssemblerX64FMA_ss) {
822 CcTest::InitializeVM();
823 if (!CpuFeatures::IsSupported(FMA3)) return;
824
825 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
826 HandleScope scope(isolate);
827 v8::internal::byte buffer[1024];
828 MacroAssembler assm(isolate, buffer, sizeof buffer);
829 {
830 CpuFeatureScope fscope(&assm, FMA3);
831 Label exit;
832 __ movss(xmm0, Operand(esp, 1 * kPointerSize));
833 __ movss(xmm1, Operand(esp, 2 * kPointerSize));
834 __ movss(xmm2, Operand(esp, 3 * kPointerSize));
835 // arguments in xmm0, xmm1 and xmm2
836 // xmm0 * xmm1 + xmm2
837 __ movaps(xmm3, xmm0);
838 __ mulss(xmm3, xmm1);
839 __ addss(xmm3, xmm2); // Expected result in xmm3
840
841 __ sub(esp, Immediate(kDoubleSize)); // For memory operand
842 // vfmadd132ss
843 __ mov(eax, Immediate(1)); // Test number
844 __ movaps(xmm4, xmm0);
845 __ vfmadd132ss(xmm4, xmm2, xmm1);
846 __ ucomiss(xmm4, xmm3);
847 __ j(not_equal, &exit);
848 // vfmadd213ss
849 __ inc(eax);
850 __ movaps(xmm4, xmm1);
851 __ vfmadd213ss(xmm4, xmm0, xmm2);
852 __ ucomiss(xmm4, xmm3);
853 __ j(not_equal, &exit);
854 // vfmadd231ss
855 __ inc(eax);
856 __ movaps(xmm4, xmm2);
857 __ vfmadd231ss(xmm4, xmm0, xmm1);
858 __ ucomiss(xmm4, xmm3);
859 __ j(not_equal, &exit);
860
861 // vfmadd132ss
862 __ inc(eax);
863 __ movaps(xmm4, xmm0);
864 __ movss(Operand(esp, 0), xmm1);
865 __ vfmadd132ss(xmm4, xmm2, Operand(esp, 0));
866 __ ucomiss(xmm4, xmm3);
867 __ j(not_equal, &exit);
868 // vfmadd213ss
869 __ inc(eax);
870 __ movaps(xmm4, xmm1);
871 __ movss(Operand(esp, 0), xmm2);
872 __ vfmadd213ss(xmm4, xmm0, Operand(esp, 0));
873 __ ucomiss(xmm4, xmm3);
874 __ j(not_equal, &exit);
875 // vfmadd231ss
876 __ inc(eax);
877 __ movaps(xmm4, xmm2);
878 __ movss(Operand(esp, 0), xmm1);
879 __ vfmadd231ss(xmm4, xmm0, Operand(esp, 0));
880 __ ucomiss(xmm4, xmm3);
881 __ j(not_equal, &exit);
882
883 // xmm0 * xmm1 - xmm2
884 __ movaps(xmm3, xmm0);
885 __ mulss(xmm3, xmm1);
886 __ subss(xmm3, xmm2); // Expected result in xmm3
887
888 // vfmsub132ss
889 __ inc(eax);
890 __ movaps(xmm4, xmm0);
891 __ vfmsub132ss(xmm4, xmm2, xmm1);
892 __ ucomiss(xmm4, xmm3);
893 __ j(not_equal, &exit);
894 // vfmadd213ss
895 __ inc(eax);
896 __ movaps(xmm4, xmm1);
897 __ vfmsub213ss(xmm4, xmm0, xmm2);
898 __ ucomiss(xmm4, xmm3);
899 __ j(not_equal, &exit);
900 // vfmsub231ss
901 __ inc(eax);
902 __ movaps(xmm4, xmm2);
903 __ vfmsub231ss(xmm4, xmm0, xmm1);
904 __ ucomiss(xmm4, xmm3);
905 __ j(not_equal, &exit);
906
907 // vfmsub132ss
908 __ inc(eax);
909 __ movaps(xmm4, xmm0);
910 __ movss(Operand(esp, 0), xmm1);
911 __ vfmsub132ss(xmm4, xmm2, Operand(esp, 0));
912 __ ucomiss(xmm4, xmm3);
913 __ j(not_equal, &exit);
914 // vfmsub213ss
915 __ inc(eax);
916 __ movaps(xmm4, xmm1);
917 __ movss(Operand(esp, 0), xmm2);
918 __ vfmsub213ss(xmm4, xmm0, Operand(esp, 0));
919 __ ucomiss(xmm4, xmm3);
920 __ j(not_equal, &exit);
921 // vfmsub231ss
922 __ inc(eax);
923 __ movaps(xmm4, xmm2);
924 __ movss(Operand(esp, 0), xmm1);
925 __ vfmsub231ss(xmm4, xmm0, Operand(esp, 0));
926 __ ucomiss(xmm4, xmm3);
927 __ j(not_equal, &exit);
928
929
930 // - xmm0 * xmm1 + xmm2
931 __ movaps(xmm3, xmm0);
932 __ mulss(xmm3, xmm1);
933 __ Move(xmm4, (uint32_t)1 << 31);
934 __ xorps(xmm3, xmm4);
935 __ addss(xmm3, xmm2); // Expected result in xmm3
936
937 // vfnmadd132ss
938 __ inc(eax);
939 __ movaps(xmm4, xmm0);
940 __ vfnmadd132ss(xmm4, xmm2, xmm1);
941 __ ucomiss(xmm4, xmm3);
942 __ j(not_equal, &exit);
943 // vfmadd213ss
944 __ inc(eax);
945 __ movaps(xmm4, xmm1);
946 __ vfnmadd213ss(xmm4, xmm0, xmm2);
947 __ ucomiss(xmm4, xmm3);
948 __ j(not_equal, &exit);
949 // vfnmadd231ss
950 __ inc(eax);
951 __ movaps(xmm4, xmm2);
952 __ vfnmadd231ss(xmm4, xmm0, xmm1);
953 __ ucomiss(xmm4, xmm3);
954 __ j(not_equal, &exit);
955
956 // vfnmadd132ss
957 __ inc(eax);
958 __ movaps(xmm4, xmm0);
959 __ movss(Operand(esp, 0), xmm1);
960 __ vfnmadd132ss(xmm4, xmm2, Operand(esp, 0));
961 __ ucomiss(xmm4, xmm3);
962 __ j(not_equal, &exit);
963 // vfnmadd213ss
964 __ inc(eax);
965 __ movaps(xmm4, xmm1);
966 __ movss(Operand(esp, 0), xmm2);
967 __ vfnmadd213ss(xmm4, xmm0, Operand(esp, 0));
968 __ ucomiss(xmm4, xmm3);
969 __ j(not_equal, &exit);
970 // vfnmadd231ss
971 __ inc(eax);
972 __ movaps(xmm4, xmm2);
973 __ movss(Operand(esp, 0), xmm1);
974 __ vfnmadd231ss(xmm4, xmm0, Operand(esp, 0));
975 __ ucomiss(xmm4, xmm3);
976 __ j(not_equal, &exit);
977
978
979 // - xmm0 * xmm1 - xmm2
980 __ movaps(xmm3, xmm0);
981 __ mulss(xmm3, xmm1);
982 __ Move(xmm4, (uint32_t)1 << 31);
983 __ xorps(xmm3, xmm4);
984 __ subss(xmm3, xmm2); // Expected result in xmm3
985
986 // vfnmsub132ss
987 __ inc(eax);
988 __ movaps(xmm4, xmm0);
989 __ vfnmsub132ss(xmm4, xmm2, xmm1);
990 __ ucomiss(xmm4, xmm3);
991 __ j(not_equal, &exit);
992 // vfmsub213ss
993 __ inc(eax);
994 __ movaps(xmm4, xmm1);
995 __ vfnmsub213ss(xmm4, xmm0, xmm2);
996 __ ucomiss(xmm4, xmm3);
997 __ j(not_equal, &exit);
998 // vfnmsub231ss
999 __ inc(eax);
1000 __ movaps(xmm4, xmm2);
1001 __ vfnmsub231ss(xmm4, xmm0, xmm1);
1002 __ ucomiss(xmm4, xmm3);
1003 __ j(not_equal, &exit);
1004
1005 // vfnmsub132ss
1006 __ inc(eax);
1007 __ movaps(xmm4, xmm0);
1008 __ movss(Operand(esp, 0), xmm1);
1009 __ vfnmsub132ss(xmm4, xmm2, Operand(esp, 0));
1010 __ ucomiss(xmm4, xmm3);
1011 __ j(not_equal, &exit);
1012 // vfnmsub213ss
1013 __ inc(eax);
1014 __ movaps(xmm4, xmm1);
1015 __ movss(Operand(esp, 0), xmm2);
1016 __ vfnmsub213ss(xmm4, xmm0, Operand(esp, 0));
1017 __ ucomiss(xmm4, xmm3);
1018 __ j(not_equal, &exit);
1019 // vfnmsub231ss
1020 __ inc(eax);
1021 __ movaps(xmm4, xmm2);
1022 __ movss(Operand(esp, 0), xmm1);
1023 __ vfnmsub231ss(xmm4, xmm0, Operand(esp, 0));
1024 __ ucomiss(xmm4, xmm3);
1025 __ j(not_equal, &exit);
1026
1027
1028 __ xor_(eax, eax);
1029 __ bind(&exit);
1030 __ add(esp, Immediate(kDoubleSize));
1031 __ ret(0);
1032 }
1033
1034 CodeDesc desc;
1035 assm.GetCode(&desc);
1036 Handle<Code> code = isolate->factory()->NewCode(
1037 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1038 #ifdef OBJECT_PRINT
1039 OFStream os(stdout);
1040 code->Print(os);
1041 #endif
1042
1043 F10 f = FUNCTION_CAST<F10>(code->entry());
1044 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f));
1045 }
592 #undef __ 1046 #undef __
OLDNEW
« no previous file with comments | « src/ia32/disasm-ia32.cc ('k') | test/cctest/test-disasm-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698