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]

[committed] Fix negation of long doubles on PA HP-UX


The enclosed change fixes the negation of long doubles on the PA under
HP-UX.  I believe that it's ok to just toggle the sign bit as the
operation is non-arithmetic and invalid exceptions don't occur when
a NaN is negated.

This patch arose from a discussion of whether PA-RISC has signed zeros.
The change fixes a few Ada test fails.

Tested on hppa2.0w-hp-hpux11.11 (4.0.0) with no regressions.  Installed
to mainline.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2005-04-10  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* pa/quadlib.c (_U_Qfneg): Toggle sign bit instead of subtracting from
	zero.

Index: config/pa/quadlib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/quadlib.c,v
retrieving revision 1.7
diff -u -3 -p -r1.7 quadlib.c
--- config/pa/quadlib.c	11 Jun 2004 23:09:58 -0000	1.7
+++ config/pa/quadlib.c	11 Apr 2005 02:21:36 -0000
@@ -160,11 +160,19 @@ _U_Qfcomp (long double a, long double b)
 }
 
 
-/* This violates the IEEE standard.  It is better to multiply by -1.0L.  */
+/* Negate long double A.  */
 long double
 _U_Qfneg (long double a)
 {
-  return (0.0L - a);
+  union
+   {
+     long double ld;
+     int i[4];
+   } u;
+
+  u.ld = a;
+  u.i[0] ^= 0x80000000;
+  return u.ld;
 }
 
 #ifdef __LP64__


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