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: [BIB PATCH] FP neg and abs using bit operations


On Sat, 7 Dec 2002, Richard Henderson wrote:
> On Fri, Dec 06, 2002 at 07:54:01PM -0700, Roger Sayle wrote:
> > 	* real.h (real_format): Add signbit field.
> > 	* real.c (ieee_single_format, ieee_double_format,
> > 	ieee_extended_motorola_format, ieee_extended_intel_96_format,
> > 	ieee_extended_intel_128_format, ibm_extended_format,
> > 	ieee_quad_format, vax_f_format, vax_d_format,
> > 	vax_g_format, i370_single_format, i370_double_format,
> > 	c4x_single_format, c4x_extended_format, real_internal_format):
> > 	Provide suitable signbit value, or -1 to avoid bit twiddling.
> >
> > 	* optabs.c (expand_unop): Try implementing negation of
> > 	floating point modes by flipping the sign bit.
> > 	(expand_abs): Try implementing abs of floating point modes
> > 	by clearing the sign bit.
>
> Ok.

Many thanks.  Applied.


> As a follow up, we'll want to properly fill in the sign bit
> position of the other formats.  The only ones that should
> have -1 are the c4x formats.

Ok.  Here's my best guess at providing values for most of the
remaining formats.  I use the value 95 for the ieee_extended_*
formats, 127 for ieee_quad_format, 15 for VAX D and F formats,
and 63 for i370 double format.  These are from my brief examination
of real.c's encode and decode functions.  The VAX formats appear
to store the sign bit in the low word, but all others in their
high word(s).

Many thanks to David Edelsohn for confirming my analysis that IBM
extended format contains two sign bits, both of which need to be
used.  We could potentially add a "signbit2" field, but I expect
that most machines that use this format have hardware floating point,
and probably include the necessary "neg?f2" and "abs?f2" instructions.
If not, for example with "-msoft-float", GCC will still synthesize
reasonable sequences: "0 - x" for neg, and "x < 0? -x : x" for abs.

I also didn't bother to change the value for real_internal_format,
as we currently only use the value of signbit to implement neg and
abs at run-time, and this struct appears to be an internal place
holder.


Unfortunately, I'm unable to test the following patch, so I'd
really appreciate it if someone more knowledgeable than I could
check that these values are reasonable before approving it.

Are these values of OK for BIB?


2002-12-07  Roger Sayle  <roger@eyesopen.com>

	* real.c (ieee_extended_motorola_format,
	ieee_extended_intel_96_format, ieee_extended_intel_128_format,
	ieee_quad_format, vax_d_format, vax_g_format, i370_double_format):
	Provide appropriate values for new signbit field.


Index: real.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/real.c,v
retrieving revision 1.75.4.12
diff -c -3 -p -r1.75.4.12 real.c
*** real.c	8 Dec 2002 00:22:46 -0000	1.75.4.12
--- real.c	8 Dec 2002 03:07:36 -0000
*************** const struct real_format ieee_extended_m
*** 3173,3179 ****
      64,
      -16382,
      16384,
!     -1,
      true,
      true,
      true,
--- 3173,3179 ----
      64,
      -16382,
      16384,
!     95,
      true,
      true,
      true,
*************** const struct real_format ieee_extended_i
*** 3190,3196 ****
      64,
      -16381,
      16384,
!     -1,
      true,
      true,
      true,
--- 3190,3196 ----
      64,
      -16381,
      16384,
!     95,
      true,
      true,
      true,
*************** const struct real_format ieee_extended_i
*** 3207,3213 ****
      64,
      -16381,
      16384,
!     -1,
      true,
      true,
      true,
--- 3207,3213 ----
      64,
      -16381,
      16384,
!     95,
      true,
      true,
      true,
*************** const struct real_format ieee_quad_forma
*** 3555,3561 ****
      113,
      -16381,
      16384,
!     -1,
      true,
      true,
      true,
--- 3555,3561 ----
      113,
      -16381,
      16384,
!     127,
      true,
      true,
      true,
*************** const struct real_format vax_d_format =
*** 3880,3886 ****
      56,
      -127,
      127,
!     -1,
      false,
      false,
      false,
--- 3880,3886 ----
      56,
      -127,
      127,
!     15,
      false,
      false,
      false,
*************** const struct real_format vax_g_format =
*** 3897,3903 ****
      53,
      -1023,
      1023,
!     -1,
      false,
      false,
      false,
--- 3897,3903 ----
      53,
      -1023,
      1023,
!     15,
      false,
      false,
      false,
*************** const struct real_format i370_double_for
*** 4096,4102 ****
      14,
      -64,
      63,
!     -1,
      false,
      false,
      false, /* ??? The encoding does allow for "unnormals".  */
--- 4096,4102 ----
      14,
      -64,
      63,
!     63,
      false,
      false,
      false, /* ??? The encoding does allow for "unnormals".  */

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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