Message ID | 1303160412-8107-14-git-send-email-aurelien@aurel32.net |
---|---|
State | New |
Headers | show |
On 18 April 2011 22:00, Aurelien Jarno <aurelien@aurel32.net> wrote: > +++ b/target-i386/op_helper.c > @@ -3440,9 +3440,10 @@ static void fpu_set_exception(int mask) > > static inline CPU86_LDouble helper_fdiv(CPU86_LDouble a, CPU86_LDouble b) > { > - if (b == 0.0) > + if (floatx_is_zero(b)) { > fpu_set_exception(FPUS_ZE); > - return a / b; > + } > + return floatx_div(a, b, &env->fp_status); > } When we get rid of softfloat-native we should be able to just use softfloat's flag-raising code and get rid of this special case of zero, right? Reviewed-by: Peter Maydell <peter.maydell@linaro.org> -- PMM
On Tue, Apr 19, 2011 at 06:11:37PM +0100, Peter Maydell wrote: > On 18 April 2011 22:00, Aurelien Jarno <aurelien@aurel32.net> wrote: > > +++ b/target-i386/op_helper.c > > @@ -3440,9 +3440,10 @@ static void fpu_set_exception(int mask) > > > > static inline CPU86_LDouble helper_fdiv(CPU86_LDouble a, CPU86_LDouble b) > > { > > - if (b == 0.0) > > + if (floatx_is_zero(b)) { > > fpu_set_exception(FPUS_ZE); > > - return a / b; > > + } > > + return floatx_div(a, b, &env->fp_status); > > } > > When we get rid of softfloat-native we should be able to just > use softfloat's flag-raising code and get rid of this special > case of zero, right? Yes, this is already in my next series adding exception support. > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > > -- PMM > >
diff --git a/target-i386/exec.h b/target-i386/exec.h index 211cc8c..b2af894 100644 --- a/target-i386/exec.h +++ b/target-i386/exec.h @@ -111,6 +111,7 @@ static inline void svm_check_intercept(uint32_t type) #define floatx_to_float32 floatx80_to_float32 #define floatx_to_float64 floatx80_to_float64 #define floatx_add floatx80_add +#define floatx_div floatx80_div #define floatx_mul floatx80_mul #define floatx_sub floatx80_sub #define floatx_abs floatx80_abs @@ -120,6 +121,7 @@ static inline void svm_check_intercept(uint32_t type) #define floatx_compare floatx80_compare #define floatx_compare_quiet floatx80_compare_quiet #define floatx_is_any_nan floatx80_is_any_nan +#define floatx_is_zero floatx80_is_zero #else #define floatx_to_int32 float64_to_int32 #define floatx_to_int64 float64_to_int64 @@ -132,6 +134,7 @@ static inline void svm_check_intercept(uint32_t type) #define floatx_to_float32 float64_to_float32 #define floatx_to_float64(x, e) (x) #define floatx_add float64_add +#define floatx_div float64_div #define floatx_mul float64_mul #define floatx_sub float64_sub #define floatx_abs float64_abs @@ -141,6 +144,7 @@ static inline void svm_check_intercept(uint32_t type) #define floatx_compare float64_compare #define floatx_compare_quiet float64_compare_quiet #define floatx_is_any_nan float64_is_any_nan +#define floatx_is_zero float64_is_zero #endif #define RC_MASK 0xc00 diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c index 9e5ca72..d0d639c 100644 --- a/target-i386/op_helper.c +++ b/target-i386/op_helper.c @@ -3440,9 +3440,10 @@ static void fpu_set_exception(int mask) static inline CPU86_LDouble helper_fdiv(CPU86_LDouble a, CPU86_LDouble b) { - if (b == 0.0) + if (floatx_is_zero(b)) { fpu_set_exception(FPUS_ZE); - return a / b; + } + return floatx_div(a, b, &env->fp_status); } static void fpu_raise_exception(void)
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> --- target-i386/exec.h | 4 ++++ target-i386/op_helper.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-)