Commit 5e4ef64cfd8cfcd8eb76c70a0d837f06ca8c5467
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 | 782 | FLOAT_OP(roundl, d) |
| 783 | 783 | { |
| 784 | 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 | 786 | RESTORE_ROUNDING_MODE; |
| 788 | 787 | update_fcr31(); |
| 789 | 788 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -792,8 +791,7 @@ FLOAT_OP(roundl, d) |
| 792 | 791 | FLOAT_OP(roundl, s) |
| 793 | 792 | { |
| 794 | 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 | 795 | RESTORE_ROUNDING_MODE; |
| 798 | 796 | update_fcr31(); |
| 799 | 797 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -802,10 +800,7 @@ FLOAT_OP(roundl, s) |
| 802 | 800 | FLOAT_OP(roundw, d) |
| 803 | 801 | { |
| 804 | 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 | 804 | RESTORE_ROUNDING_MODE; |
| 810 | 805 | update_fcr31(); |
| 811 | 806 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -814,8 +809,7 @@ FLOAT_OP(roundw, d) |
| 814 | 809 | FLOAT_OP(roundw, s) |
| 815 | 810 | { |
| 816 | 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 | 813 | RESTORE_ROUNDING_MODE; |
| 820 | 814 | update_fcr31(); |
| 821 | 815 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -854,8 +848,7 @@ FLOAT_OP(truncw, s) |
| 854 | 848 | FLOAT_OP(ceill, d) |
| 855 | 849 | { |
| 856 | 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 | 852 | RESTORE_ROUNDING_MODE; |
| 860 | 853 | update_fcr31(); |
| 861 | 854 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -864,8 +857,7 @@ FLOAT_OP(ceill, d) |
| 864 | 857 | FLOAT_OP(ceill, s) |
| 865 | 858 | { |
| 866 | 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 | 861 | RESTORE_ROUNDING_MODE; |
| 870 | 862 | update_fcr31(); |
| 871 | 863 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -874,10 +866,7 @@ FLOAT_OP(ceill, s) |
| 874 | 866 | FLOAT_OP(ceilw, d) |
| 875 | 867 | { |
| 876 | 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 | 870 | RESTORE_ROUNDING_MODE; |
| 882 | 871 | update_fcr31(); |
| 883 | 872 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -886,8 +875,7 @@ FLOAT_OP(ceilw, d) |
| 886 | 875 | FLOAT_OP(ceilw, s) |
| 887 | 876 | { |
| 888 | 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 | 879 | RESTORE_ROUNDING_MODE; |
| 892 | 880 | update_fcr31(); |
| 893 | 881 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -897,8 +885,7 @@ FLOAT_OP(ceilw, s) |
| 897 | 885 | FLOAT_OP(floorl, d) |
| 898 | 886 | { |
| 899 | 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 | 889 | RESTORE_ROUNDING_MODE; |
| 903 | 890 | update_fcr31(); |
| 904 | 891 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -907,8 +894,7 @@ FLOAT_OP(floorl, d) |
| 907 | 894 | FLOAT_OP(floorl, s) |
| 908 | 895 | { |
| 909 | 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 | 898 | RESTORE_ROUNDING_MODE; |
| 913 | 899 | update_fcr31(); |
| 914 | 900 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -917,10 +903,7 @@ FLOAT_OP(floorl, s) |
| 917 | 903 | FLOAT_OP(floorw, d) |
| 918 | 904 | { |
| 919 | 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 | 907 | RESTORE_ROUNDING_MODE; |
| 925 | 908 | update_fcr31(); |
| 926 | 909 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) |
| ... | ... | @@ -929,8 +912,7 @@ FLOAT_OP(floorw, d) |
| 929 | 912 | FLOAT_OP(floorw, s) |
| 930 | 913 | { |
| 931 | 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 | 916 | RESTORE_ROUNDING_MODE; |
| 935 | 917 | update_fcr31(); |
| 936 | 918 | if (GET_FP_CAUSE(env->fcr31) & (FP_OVERFLOW | FP_INVALID)) | ... | ... |