This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: mips SNaN/QNaN is swapped


On Tue, Apr 01, 2003 at 12:19:33AM -0300, Alexandre Oliva wrote:
> 	* real.h (EXP_BITS): Make room for...
> 	(struct real_value): ... added canonical bit.
> 	(struct real_format): Added pnan.
> 	(mips_single_format, mips_double_format, mips_extended_format,
> 	mips_quad_format): New.
> 	* real.c: Copy p to pnan in all formats.
> 	 (get_canonical_qnan, get_canonical_snan): Set canonical bit.
> 	(real_nan): Use pnan to compute significand's shift.
> 	(encode_ieee_single, encode_ieee_double, encode_ieee_quad):
> 	Set all bits of canonical nan if !qnan_msb_set.
> 	(encode_ibm_extended, decode_ibm_extended): Likewise.  Use
> 	qnan_msb_set to tell the base double format.
> 	(ibm_extended_format): Use 53 as pnan.
> 	(mips_single_format, mips_double_format, mips_extended_format,
> 	mips_quad_format): Copied from the corresponding ieee/ibm
> 	formats, with qnan_msb_set false.

Almost ok.

You've missed the needed change to real_identical.  In this case,
if canonical, you should ignore the significand.  This implies a
needed change to real_hash as well.

> +	  /* We overload qnan_msb_set here: it's only clear for
> +	     mips_ieee_single, which wants all mantissa bits but the
> +	     quiet/signalling one set in canonical NaNs (at least
> +	     Quiet ones).  */
> +	  if (r->canonical && !fmt->qnan_msb_set)
> +	    sig |= (1 << 22) - 1;
> +	  else if (sig == 0)
>  	    sig = 1 << 21;

And further implies that canonical should ignore the existing value
of sig.  I.e. something like

	if (r->canonical)
	  sig = (fmt->qnan_msb_set ? (1 << 22) - 1 : 1 << 21);
	else if (sig == 0)
	  sig = 1 << 21;



r~


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