This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix underflow and inexact signalling in soft-fp whenpacking.


On Fri, 25 May 2012, David Miller wrote:

> 	* soft-fp/op-common.h (_FP_PACK_CANONICAL): Only set underflow if
> 	the underflow exception is enabled and the non-zero result is
> 	tiny, or the non-zero result is tiny and there will be a loss of
> 	accuracy.  Set inexact if overflow is detected after rounding, but
> 	not if it is detected before.

I think _FP_PACK_SEMIRAW needs a similar fix.

> @@ -220,7 +220,6 @@ 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))			\
>  	      {							\

Is this "if" case now possible, with the rounding no longer happening 
here?

> @@ -229,10 +228,23 @@ do {								\
>  	      }							\
>  	    else						\
>  	      {							\
> -		X##_e = 0;					\
> -		_FP_FRAC_SRL_##wc(X, _FP_WORKBITS);		\
> -		FP_SET_EXCEPTION(FP_EX_UNDERFLOW);		\
> +		_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);		\
> +		  }						\

Equivalently, this looks like it might be a bigger change than necessary - 
as if the substance of what you are doing is really just removing the 
underflow exception setting from the existing "else" case, and putting the 
code after it that properly checks for "inexact".

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]