Commit 5e4ef64cfd8cfcd8eb76c70a0d837f06ca8c5467

Authored by ths
1 parent ea6e4fe2

Simplify round/ceil/floor implementation, spotted by Fabrice Bellard.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3031 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 12 additions and 30 deletions
target-mips/op_helper.c
@@ -782,8 +782,7 @@ FLOAT_OP(cvtw, d) @@ -782,8 +782,7 @@ FLOAT_OP(cvtw, d)
782 FLOAT_OP(roundl, d) 782 FLOAT_OP(roundl, d)
783 { 783 {
784 set_float_rounding_mode(float_round_nearest_even, &env->fp_status); 784 set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
785 - DT2 = float64_round_to_int(FDT0, &env->fp_status);  
786 - DT2 = float64_to_int64(DT2, &env->fp_status); 785 + DT2 = float64_to_int64(FDT0, &env->fp_status);
787 RESTORE_ROUNDING_MODE; 786 RESTORE_ROUNDING_MODE;
788 update_fcr31(); 787 update_fcr31();
789 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 788 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -792,8 +791,7 @@ FLOAT_OP(roundl, d) @@ -792,8 +791,7 @@ FLOAT_OP(roundl, d)
792 FLOAT_OP(roundl, s) 791 FLOAT_OP(roundl, s)
793 { 792 {
794 set_float_rounding_mode(float_round_nearest_even, &env->fp_status); 793 set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
795 - WT2 = float32_round_to_int(FST0, &env->fp_status);  
796 - DT2 = float32_to_int64(WT2, &env->fp_status); 794 + DT2 = float32_to_int64(FST0, &env->fp_status);
797 RESTORE_ROUNDING_MODE; 795 RESTORE_ROUNDING_MODE;
798 update_fcr31(); 796 update_fcr31();
799 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 797 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -802,10 +800,7 @@ FLOAT_OP(roundl, s) @@ -802,10 +800,7 @@ FLOAT_OP(roundl, s)
802 FLOAT_OP(roundw, d) 800 FLOAT_OP(roundw, d)
803 { 801 {
804 set_float_rounding_mode(float_round_nearest_even, &env->fp_status); 802 set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
805 - DT2 = float64_round_to_int(FDT0, &env->fp_status);  
806 -// ???  
807 - env->fp_status.float_exception_flags &= ~float_flag_inexact;  
808 - WT2 = float64_to_int32(DT2, &env->fp_status); 803 + WT2 = float64_to_int32(FDT0, &env->fp_status);
809 RESTORE_ROUNDING_MODE; 804 RESTORE_ROUNDING_MODE;
810 update_fcr31(); 805 update_fcr31();
811 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 806 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -814,8 +809,7 @@ FLOAT_OP(roundw, d) @@ -814,8 +809,7 @@ FLOAT_OP(roundw, d)
814 FLOAT_OP(roundw, s) 809 FLOAT_OP(roundw, s)
815 { 810 {
816 set_float_rounding_mode(float_round_nearest_even, &env->fp_status); 811 set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
817 - WT2 = float32_round_to_int(FST0, &env->fp_status);  
818 - WT2 = float32_to_int32(WT2, &env->fp_status); 812 + WT2 = float32_to_int32(FST0, &env->fp_status);
819 RESTORE_ROUNDING_MODE; 813 RESTORE_ROUNDING_MODE;
820 update_fcr31(); 814 update_fcr31();
821 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 815 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -854,8 +848,7 @@ FLOAT_OP(truncw, s) @@ -854,8 +848,7 @@ FLOAT_OP(truncw, s)
854 FLOAT_OP(ceill, d) 848 FLOAT_OP(ceill, d)
855 { 849 {
856 set_float_rounding_mode(float_round_up, &env->fp_status); 850 set_float_rounding_mode(float_round_up, &env->fp_status);
857 - DT2 = float64_round_to_int(FDT0, &env->fp_status);  
858 - DT2 = float64_to_int64(DT2, &env->fp_status); 851 + DT2 = float64_to_int64(FDT0, &env->fp_status);
859 RESTORE_ROUNDING_MODE; 852 RESTORE_ROUNDING_MODE;
860 update_fcr31(); 853 update_fcr31();
861 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 854 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -864,8 +857,7 @@ FLOAT_OP(ceill, d) @@ -864,8 +857,7 @@ FLOAT_OP(ceill, d)
864 FLOAT_OP(ceill, s) 857 FLOAT_OP(ceill, s)
865 { 858 {
866 set_float_rounding_mode(float_round_up, &env->fp_status); 859 set_float_rounding_mode(float_round_up, &env->fp_status);
867 - WT2 = float32_round_to_int(FST0, &env->fp_status);  
868 - DT2 = float32_to_int64(WT2, &env->fp_status); 860 + DT2 = float32_to_int64(FST0, &env->fp_status);
869 RESTORE_ROUNDING_MODE; 861 RESTORE_ROUNDING_MODE;
870 update_fcr31(); 862 update_fcr31();
871 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 863 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -874,10 +866,7 @@ FLOAT_OP(ceill, s) @@ -874,10 +866,7 @@ FLOAT_OP(ceill, s)
874 FLOAT_OP(ceilw, d) 866 FLOAT_OP(ceilw, d)
875 { 867 {
876 set_float_rounding_mode(float_round_up, &env->fp_status); 868 set_float_rounding_mode(float_round_up, &env->fp_status);
877 - DT2 = float64_round_to_int(FDT0, &env->fp_status);  
878 -// ???  
879 - env->fp_status.float_exception_flags &= ~float_flag_inexact;  
880 - WT2 = float64_to_int32(DT2, &env->fp_status); 869 + WT2 = float64_to_int32(FDT0, &env->fp_status);
881 RESTORE_ROUNDING_MODE; 870 RESTORE_ROUNDING_MODE;
882 update_fcr31(); 871 update_fcr31();
883 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 872 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -886,8 +875,7 @@ FLOAT_OP(ceilw, d) @@ -886,8 +875,7 @@ FLOAT_OP(ceilw, d)
886 FLOAT_OP(ceilw, s) 875 FLOAT_OP(ceilw, s)
887 { 876 {
888 set_float_rounding_mode(float_round_up, &env->fp_status); 877 set_float_rounding_mode(float_round_up, &env->fp_status);
889 - WT2 = float32_round_to_int(FST0, &env->fp_status);  
890 - WT2 = float32_to_int32(WT2, &env->fp_status); 878 + WT2 = float32_to_int32(FST0, &env->fp_status);
891 RESTORE_ROUNDING_MODE; 879 RESTORE_ROUNDING_MODE;
892 update_fcr31(); 880 update_fcr31();
893 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 881 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -897,8 +885,7 @@ FLOAT_OP(ceilw, s) @@ -897,8 +885,7 @@ FLOAT_OP(ceilw, s)
897 FLOAT_OP(floorl, d) 885 FLOAT_OP(floorl, d)
898 { 886 {
899 set_float_rounding_mode(float_round_down, &env->fp_status); 887 set_float_rounding_mode(float_round_down, &env->fp_status);
900 - DT2 = float64_round_to_int(FDT0, &env->fp_status);  
901 - DT2 = float64_to_int64(DT2, &env->fp_status); 888 + DT2 = float64_to_int64(FDT0, &env->fp_status);
902 RESTORE_ROUNDING_MODE; 889 RESTORE_ROUNDING_MODE;
903 update_fcr31(); 890 update_fcr31();
904 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 891 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -907,8 +894,7 @@ FLOAT_OP(floorl, d) @@ -907,8 +894,7 @@ FLOAT_OP(floorl, d)
907 FLOAT_OP(floorl, s) 894 FLOAT_OP(floorl, s)
908 { 895 {
909 set_float_rounding_mode(float_round_down, &env->fp_status); 896 set_float_rounding_mode(float_round_down, &env->fp_status);
910 - WT2 = float32_round_to_int(FST0, &env->fp_status);  
911 - DT2 = float32_to_int64(WT2, &env->fp_status); 897 + DT2 = float32_to_int64(FST0, &env->fp_status);
912 RESTORE_ROUNDING_MODE; 898 RESTORE_ROUNDING_MODE;
913 update_fcr31(); 899 update_fcr31();
914 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 900 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -917,10 +903,7 @@ FLOAT_OP(floorl, s) @@ -917,10 +903,7 @@ FLOAT_OP(floorl, s)
917 FLOAT_OP(floorw, d) 903 FLOAT_OP(floorw, d)
918 { 904 {
919 set_float_rounding_mode(float_round_down, &env->fp_status); 905 set_float_rounding_mode(float_round_down, &env->fp_status);
920 - DT2 = float64_round_to_int(FDT0, &env->fp_status);  
921 -// ???  
922 - env->fp_status.float_exception_flags &= ~float_flag_inexact;  
923 - WT2 = float64_to_int32(DT2, &env->fp_status); 906 + WT2 = float64_to_int32(FDT0, &env->fp_status);
924 RESTORE_ROUNDING_MODE; 907 RESTORE_ROUNDING_MODE;
925 update_fcr31(); 908 update_fcr31();
926 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 909 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))
@@ -929,8 +912,7 @@ FLOAT_OP(floorw, d) @@ -929,8 +912,7 @@ FLOAT_OP(floorw, d)
929 FLOAT_OP(floorw, s) 912 FLOAT_OP(floorw, s)
930 { 913 {
931 set_float_rounding_mode(float_round_down, &env->fp_status); 914 set_float_rounding_mode(float_round_down, &env->fp_status);
932 - WT2 = float32_round_to_int(FST0, &env->fp_status);  
933 - WT2 = float32_to_int32(WT2, &env->fp_status); 915 + WT2 = float32_to_int32(FST0, &env->fp_status);
934 RESTORE_ROUNDING_MODE; 916 RESTORE_ROUNDING_MODE;
935 update_fcr31(); 917 update_fcr31();
936 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) 918 if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID))