Re: math-emu issue with fp divide

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Miller <davem@...>
Cc: <joseph@...>, <linux-kernel@...>, <libc-alpha@...>
Date: Thursday, June 5, 2008 - 9:38 am

On Wed, 4 Jun 2008, David Miller wrote:


Now that I'm digging into this a bit I'm thinking my issue has to do with
the fix you put in place from back in Aug 2007 (commit
405849610fd96b4f34cd1875c4c033228fea6c0f):

[MATH-EMU]: Fix underflow exception reporting.

    2) we ended up rounding back up to normal (this is the case where
       we set the exponent to 1 and set the fraction to zero), this
       should set inexact too
...

    Another example, "0x0.0000000000001p-1022 / 16.0", should signal both
    inexact and underflow.  The cpu implementations and ieee1754
    literature is very clear about this.  This is case #2 above.

I'm not clear from your commit comment on what actual number
0x0.0....01p-1022 is?

It looks like the case I have we are exact before rounding, but think it
looks like the rounding case since it appears as if "overflow is set".

000.FFFFFFFFFFFFF / 3FE.FFFFFFFFFFFFE = 001.0000000000000

I think the following adds the check for my case and still works for the
issue your commit was trying to resolve.  Take a look any and all comments
are welcome since this code is pretty complicated:

- k

diff --git a/include/math-emu/op-common.h b/include/math-emu/op-common.h
index cc1ec39..bc50aa0 100644
--- a/include/math-emu/op-common.h
+++ b/include/math-emu/op-common.h
@@ -139,18 +139,27 @@ do {								\
 	if (X##_e <= _FP_WFRACBITS_##fs)			\
 	  {							\
 	    _FP_FRAC_SRS_##wc(X, X##_e, _FP_WFRACBITS_##fs);	\
-	    _FP_ROUND(wc, X);					\
 	    if (_FP_FRAC_HIGH_##fs(X)				\
 		& (_FP_OVERFLOW_##fs >> 1))			\
 	      {							\
 	        X##_e = 1;					\
 	        _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc);	\
-	        FP_SET_EXCEPTION(FP_EX_INEXACT);		\
 	      }							\
 	    else						\
 	      {							\
-		X##_e = 0;					\
-		_FP_FRAC_SRL_##wc(X, _FP_WORKBITS);		\
+		_FP_ROUND(wc, X);				\
+		if (_FP_FRAC_HIGH_##fs(X)			\
+		   & (_FP_OVERFLOW_##fs >> 1))			\
+		  {						\
+		    X##_e = 1;					\
+		    _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc);	\
+		    FP_SET_EXCEPTION(FP_EX_INEXACT);		\
+		  }						\
+		else						\
+		  {						\
+		    X##_e = 0;					\
+		    _FP_FRAC_SRL_##wc(X, _FP_WORKBITS);		\
+		  }						\
 	      }							\
 	    if ((FP_CUR_EXCEPTIONS & FP_EX_INEXACT) ||		\
 		(FP_TRAPPING_EXCEPTIONS & FP_EX_UNDERFLOW))	\
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
math-emu issue with fp divide, Kumar Gala, (Wed Jun 4, 4:38 pm)
Re: math-emu issue with fp divide, Joseph S. Myers, (Wed Jun 4, 5:42 pm)
Re: math-emu issue with fp divide, David Miller, (Wed Jun 4, 5:49 pm)
Re: math-emu issue with fp divide, Kumar Gala, (Thu Jun 5, 9:38 am)
Re: math-emu issue with fp divide, David Miller, (Fri Jun 13, 12:24 am)
Re: math-emu issue with fp divide, Kumar Gala, (Fri Jun 27, 10:15 am)
Re: math-emu issue with fp divide, David Miller, (Wed Oct 22, 1:15 am)
Re: math-emu issue with fp divide, Kumar Gala, (Fri Jun 27, 9:48 am)
Re: math-emu issue with fp divide, David Miller, (Fri Jun 27, 6:54 pm)
Re: math-emu issue with fp divide, Kumar Gala, (Fri Jun 13, 11:49 am)
Re: math-emu issue with fp divide, David Miller, (Wed Jun 4, 5:37 pm)