public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/25960]  New: __gcc_add doesn't handle -0.0L properly
@ 2006-01-25 14:31 jakub at gcc dot gnu dot org
  2006-01-25 14:39 ` [Bug target/25960] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2006-01-25 14:31 UTC (permalink / raw)
  To: gcc-bugs

volatile long double l, m, n;

extern void abort (void);
int
main (void)
{
  l = __builtin_copysignl (0.0L, -1.0L);
  m = __builtin_copysignl (0.0L, -1.0L);
  n = l + m;
  if (__builtin_copysignl (1.0L, n) >= 0.0L)
    abort ();
  return 0;
}

fails on ppc*-linux with -mlong-double-128, -0.0 + -0.0 gives 0.0 rather than
expected -0.0.


-- 
           Summary: __gcc_add doesn't handle -0.0L properly
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
GCC target triplet: powerpc*-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_add doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
@ 2006-01-25 14:39 ` pinskia at gcc dot gnu dot org
  2006-01-27 17:59 ` dje at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-25 14:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-01-25 14:39 -------
Confirmed on powerpc-darwin also which uses IBM's 128bit long double format by
default.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |geoffk at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
 GCC target triplet|powerpc*-linux              |powerpc*-*
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2006-01-25 14:39:25
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_add doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
  2006-01-25 14:39 ` [Bug target/25960] " pinskia at gcc dot gnu dot org
@ 2006-01-27 17:59 ` dje at gcc dot gnu dot org
  2006-01-27 18:02 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dje at gcc dot gnu dot org @ 2006-01-27 17:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dje at gcc dot gnu dot org  2006-01-27 17:59 -------
The IBM 128-bit extended floating point format is not fully compliant with IEEE
754.  It is functioning as designed.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_add doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
  2006-01-25 14:39 ` [Bug target/25960] " pinskia at gcc dot gnu dot org
  2006-01-27 17:59 ` dje at gcc dot gnu dot org
@ 2006-01-27 18:02 ` pinskia at gcc dot gnu dot org
  2006-02-02  4:30 ` amodra at bigpond dot net dot au
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-27 18:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-01-27 18:02 -------
So closing as invalid.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_add doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-01-27 18:02 ` pinskia at gcc dot gnu dot org
@ 2006-02-02  4:30 ` amodra at bigpond dot net dot au
  2006-02-02  6:18 ` amodra at bigpond dot net dot au
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at bigpond dot net dot au @ 2006-02-02  4:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from amodra at bigpond dot net dot au  2006-02-02 04:30 -------
I don't think this bug should have been closed so quickly.  Fixing __gcc_qadd
to properly handle a -0 result is trivial, and only costs one extra compare and
branch.  The multiply and divide support in darwin-ldouble.c already have
special code for -0, with a comment "Preserve -0", so I think lack of such a
test in __gcc_qadd is simply an oversight.


-- 

amodra at bigpond dot net dot au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |munroesj at us dot ibm dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_add doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-02-02  4:30 ` amodra at bigpond dot net dot au
@ 2006-02-02  6:18 ` amodra at bigpond dot net dot au
  2006-02-02  8:50 ` geoffk at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at bigpond dot net dot au @ 2006-02-02  6:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from amodra at bigpond dot net dot au  2006-02-02 06:18 -------
        * config/rs6000/darwin-ldouble.c (__gcc_qadd): Preserve -0.0 result.

Index: gcc/config/rs6000/darwin-ldouble.c
===================================================================
--- gcc/config/rs6000/darwin-ldouble.c  (revision 110484)
+++ gcc/config/rs6000/darwin-ldouble.c  (working copy)
@@ -117,10 +117,15 @@ __gcc_qadd (double a, double aa, double 
     {
       q = a - z;
       zz = q + c + (a - (q + z)) + aa + cc;
-      xh = z + zz;
-
-      if (nonfinite (xh))
-       return xh;
+      xh = z;
+      /* Keep -0 result.  */
+      if (zz != 0.0)
+       {
+         xh += zz;
+
+         if (nonfinite (xh))
+           return xh;
+       }

       x.dval[0] = xh;
       x.dval[1] = z - xh + zz;


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_add doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-02-02  6:18 ` amodra at bigpond dot net dot au
@ 2006-02-02  8:50 ` geoffk at gcc dot gnu dot org
  2006-02-02 23:32 ` amodra at bigpond dot net dot au
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2006-02-02  8:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from geoffk at gcc dot gnu dot org  2006-02-02 08:50 -------
I agree with Alan.

Although the format is not compatible with IEEE arithmetic, this applies only
because the arithmetic is different, not the handling of special cases.  In
every case where the inputs are exactly representable as a double (including
+/-0, Inf, and NaN) and 'double' arithmetic would be exact, the result of the
computation in this 'long double' representation should be the same as if it
had been done in 'double'.

As for the patch, it looks right to me, but it's probably better for
performance if instead it does

if (zz == 0.0)
  return z;


-- 

geoffk at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_add doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-02-02  8:50 ` geoffk at gcc dot gnu dot org
@ 2006-02-02 23:32 ` amodra at bigpond dot net dot au
  2006-02-03 11:44 ` [Bug target/25960] __gcc_qadd " amodra at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at bigpond dot net dot au @ 2006-02-02 23:32 UTC (permalink / raw)
  To: gcc-bugs



-- 

amodra at bigpond dot net dot au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |amodra at bigpond dot net
                   |dot org                     |dot au
             Status|REOPENED                    |ASSIGNED
   Last reconfirmed|2006-01-25 14:39:25         |2006-02-02 23:32:19
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_qadd doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-02-02 23:32 ` amodra at bigpond dot net dot au
@ 2006-02-03 11:44 ` amodra at gcc dot gnu dot org
  2006-02-03 12:06 ` amodra at gcc dot gnu dot org
  2006-02-03 12:07 ` amodra at bigpond dot net dot au
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gcc dot gnu dot org @ 2006-02-03 11:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from amodra at gcc dot gnu dot org  2006-02-03 11:44 -------
Subject: Bug 25960

Author: amodra
Date: Fri Feb  3 11:44:08 2006
New Revision: 110540

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110540
Log:
        PR target/25960
gcc/
        * config/rs6000/darwin-ldouble.c (__gcc_qadd): Preserve -0.0 result.
gcc/testsuite/
        * gcc.target/powerpc/pr25960.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr25960.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/darwin-ldouble.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_qadd doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-02-03 11:44 ` [Bug target/25960] __gcc_qadd " amodra at gcc dot gnu dot org
@ 2006-02-03 12:06 ` amodra at gcc dot gnu dot org
  2006-02-03 12:07 ` amodra at bigpond dot net dot au
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at gcc dot gnu dot org @ 2006-02-03 12:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from amodra at gcc dot gnu dot org  2006-02-03 12:05 -------
Subject: Bug 25960

Author: amodra
Date: Fri Feb  3 12:05:51 2006
New Revision: 110542

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110542
Log:
        PR target/25960
gcc/
        * config/rs6000/darwin-ldouble.c (__gcc_qadd): Preserve -0.0 result.
gcc/testsuite/
        * gcc.target/powerpc/pr25960.c: New test.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.target/powerpc/pr25960.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/rs6000/darwin-ldouble.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/25960] __gcc_qadd doesn't handle -0.0L properly
  2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2006-02-03 12:06 ` amodra at gcc dot gnu dot org
@ 2006-02-03 12:07 ` amodra at bigpond dot net dot au
  9 siblings, 0 replies; 11+ messages in thread
From: amodra at bigpond dot net dot au @ 2006-02-03 12:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from amodra at bigpond dot net dot au  2006-02-03 12:07 -------
Fixed 4.1 and mainline


-- 

amodra at bigpond dot net dot au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25960


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-02-03 12:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-25 14:31 [Bug target/25960] New: __gcc_add doesn't handle -0.0L properly jakub at gcc dot gnu dot org
2006-01-25 14:39 ` [Bug target/25960] " pinskia at gcc dot gnu dot org
2006-01-27 17:59 ` dje at gcc dot gnu dot org
2006-01-27 18:02 ` pinskia at gcc dot gnu dot org
2006-02-02  4:30 ` amodra at bigpond dot net dot au
2006-02-02  6:18 ` amodra at bigpond dot net dot au
2006-02-02  8:50 ` geoffk at gcc dot gnu dot org
2006-02-02 23:32 ` amodra at bigpond dot net dot au
2006-02-03 11:44 ` [Bug target/25960] __gcc_qadd " amodra at gcc dot gnu dot org
2006-02-03 12:06 ` amodra at gcc dot gnu dot org
2006-02-03 12:07 ` amodra at bigpond dot net dot au

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).