public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/28634]  New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips
@ 2006-08-07 12:52 tbm at cyrius dot com
  2006-08-08  0:29 ` [Bug target/28634] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: tbm at cyrius dot com @ 2006-08-07 12:52 UTC (permalink / raw)
  To: gcc-bugs

[ forwarded from http://bugs.debian.org/381710 ]

The following report has been submitted by Kurt Roeckx:

I've been looking at the perl testsuite failure on hppa.  See
http://bugs.debian.org/374396

This code:
        while (cdouble < 0.0)
                cdouble += adouble;

Generated by gcc-4.1 with -O2 and -fdelayed-branch gives:
        fadd,dbl %fr13,%fr22,%fr13
 .L1447:
        fcmp,dbl,!< %fr13,%fr0
        ftest
        b .L1447
        fadd,dbl %fr13,%fr22,%fr13
        fsub,dbl %fr13,%fr22,%fr13

With -O2 and -fno-delayed-branch:
.L1239:
        fadd,dbl %fr13,%fr22,%fr13
        fcmp,dbl,!< %fr13,%fr0
        ftest
        b,n .L1239

As you can see, in case of the delayed branches it always
executes an fadd at the start and fsub at the end, which it
doesn't do without the delayed branches.

This is causing unwanted rounding problems, since the mantisa
doesn't have enough bits to keep the the required information.
I think atleast in this case, it's not a good idea to do this
optimization with floating point numbers.

The same code on gcc-4.0 with -fdelayed-branch seems to generate
this code:
.L661:
        fadd,dbl %fr12,%fr22,%fr12
        fcmp,dbl,!< %fr12,%fr0
        ftest
        b .L661
        ldo -256(%r30),%r20

With -fno-delayed-branch:
.L643:
        fadd,dbl %fr12,%fr22,%fr12
        fcmp,dbl,!< %fr12,%fr0
        ftest
        b,n .L643

So gcc-4.0 looks good.

gcc-snapshot 20060721-1 gives with -fdelayed-branch:
        fadd,dbl %fr12,%fr22,%fr12
.L1449:
        fcmp,dbl,!< %fr12,%fr0
        ftest
        b .L1449
        fadd,dbl %fr12,%fr22,%fr12
        fsub,dbl %fr12,%fr22,%fr12

So that has the same problem.

For those not familiar with hppa assembler, a branch normally
executes the instruction following it too, before branching.
The ",n" in "b,n" will prevent the next instruction from being
executed, so has the same effect as following it with a nop
instruction.


The following code has the same effect:

#include <stdio.h>
double cdouble = -1;
int     main()
{
        double adouble;

        adouble = 9007199254740992.0; /* 2^53 */
        while (cdouble < 0.0)
                cdouble += adouble;
        printf("%lf\n", cdouble);
        return 0;
}

With delayed branches it prints:
9007199254740992.000000
without:
9007199254740991.000000


-- 
           Summary: [4.1/4.2 regression] rounding problem with -fdelayed-
                    branch on hppa/mips
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tbm at cyrius dot com


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


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

* [Bug target/28634] [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips
  2006-08-07 12:52 [Bug tree-optimization/28634] New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips tbm at cyrius dot com
@ 2006-08-08  0:29 ` pinskia at gcc dot gnu dot org
  2006-08-08  0:35 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-08  0:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-08-08 00:29 -------
This sounds like two target problems rather than generic ones.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |target
 GCC target triplet|hppa-linux-gnu              |hppa-linux-gnu, mips-linux-
                   |                            |gnu


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


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

* [Bug target/28634] [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips
  2006-08-07 12:52 [Bug tree-optimization/28634] New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips tbm at cyrius dot com
  2006-08-08  0:29 ` [Bug target/28634] " pinskia at gcc dot gnu dot org
@ 2006-08-08  0:35 ` pinskia at gcc dot gnu dot org
  2006-08-13  8:34 ` [Bug rtl-optimization/28634] " rsandifo at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-08  0:35 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.2


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


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

* [Bug rtl-optimization/28634] [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips
  2006-08-07 12:52 [Bug tree-optimization/28634] New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips tbm at cyrius dot com
  2006-08-08  0:29 ` [Bug target/28634] " pinskia at gcc dot gnu dot org
  2006-08-08  0:35 ` pinskia at gcc dot gnu dot org
@ 2006-08-13  8:34 ` rsandifo at gcc dot gnu dot org
  2006-08-14 11:56 ` rsandifo at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2006-08-13  8:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rsandifo at gcc dot gnu dot org  2006-08-13 08:34 -------
Re comment #1: it's a generic bug in reorg.c (fill_slots_from_thread).

I'm testing a patch.


-- 

rsandifo at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rsandifo at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
          Component|target                      |rtl-optimization
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-08-13 08:34:50
               date|                            |


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


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

* [Bug rtl-optimization/28634] [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips
  2006-08-07 12:52 [Bug tree-optimization/28634] New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips tbm at cyrius dot com
                   ` (2 preceding siblings ...)
  2006-08-13  8:34 ` [Bug rtl-optimization/28634] " rsandifo at gcc dot gnu dot org
@ 2006-08-14 11:56 ` rsandifo at gcc dot gnu dot org
  2006-08-14 11:58 ` [Bug rtl-optimization/28634] [4.1 " rsandifo at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2006-08-14 11:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rsandifo at gcc dot gnu dot org  2006-08-14 11:56 -------
Subject: Bug 28634

Author: rsandifo
Date: Mon Aug 14 12:55:52 2006
New Revision: 116124

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116124
Log:
gcc/
        PR rtl-optimization/28634
        * reorg.c (fill_slots_from_thread): Do not assume A + X - X == A
        for floating-point modes unless flag_unsafe_math_optimizations.

gcc/testsuite/
        PR rtl-optimization/28634
        * gcc.c-torture/execute/ieee/pr28634.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/ieee/pr28634.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reorg.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug rtl-optimization/28634] [4.1 regression] rounding problem with -fdelayed-branch on hppa/mips
  2006-08-07 12:52 [Bug tree-optimization/28634] New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips tbm at cyrius dot com
                   ` (3 preceding siblings ...)
  2006-08-14 11:56 ` rsandifo at gcc dot gnu dot org
@ 2006-08-14 11:58 ` rsandifo at gcc dot gnu dot org
  2006-09-09 10:56 ` rsandifo at gcc dot gnu dot org
  2006-09-09 11:01 ` [Bug rtl-optimization/28634] " rsandifo at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2006-08-14 11:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rsandifo at gcc dot gnu dot org  2006-08-14 11:58 -------
Patch applied to mainline.  It has been approved for 4.1,
so I'll apply it there after testing.


-- 

rsandifo at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|4.1.0 4.2.0                 |4.1.0
      Known to work|4.0.3                       |4.0.3 4.2.0
            Summary|[4.1/4.2 regression]        |[4.1 regression] rounding
                   |rounding problem with -     |problem with -fdelayed-
                   |fdelayed-branch on hppa/mips|branch on hppa/mips


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


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

* [Bug rtl-optimization/28634] [4.1 regression] rounding problem with -fdelayed-branch on hppa/mips
  2006-08-07 12:52 [Bug tree-optimization/28634] New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips tbm at cyrius dot com
                   ` (4 preceding siblings ...)
  2006-08-14 11:58 ` [Bug rtl-optimization/28634] [4.1 " rsandifo at gcc dot gnu dot org
@ 2006-09-09 10:56 ` rsandifo at gcc dot gnu dot org
  2006-09-09 11:01 ` [Bug rtl-optimization/28634] " rsandifo at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2006-09-09 10:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rsandifo at gcc dot gnu dot org  2006-09-09 10:56 -------
Subject: Bug 28634

Author: rsandifo
Date: Sat Sep  9 10:56:31 2006
New Revision: 116796

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116796
Log:
gcc/
        PR rtl-optimization/28634
        * reorg.c (fill_slots_from_thread): Do not assume A + X - X == A
        for floating-point modes unless flag_unsafe_math_optimizations.

gcc/testsuite/
        PR rtl-optimization/28634
        * gcc.c-torture/execute/ieee/pr28634.c: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/execute/ieee/pr28634.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/reorg.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug rtl-optimization/28634] rounding problem with -fdelayed-branch on hppa/mips
  2006-08-07 12:52 [Bug tree-optimization/28634] New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips tbm at cyrius dot com
                   ` (5 preceding siblings ...)
  2006-09-09 10:56 ` rsandifo at gcc dot gnu dot org
@ 2006-09-09 11:01 ` rsandifo at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2006-09-09 11:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rsandifo at gcc dot gnu dot org  2006-09-09 11:01 -------
Applied to 4.1 after testing on mipsisa64-elf and mips64-linux-gnu.
Although the bug has been around for a long time, it isn't known to
be a regression from 4.0 to some earlier release, so it doesn't
qualify for a 4.0 backport.  I'll therefore close this PR as fixed.


-- 

rsandifo at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|4.1.0                       |4.1.1
      Known to work|4.0.3 4.2.0                 |4.0.3 4.1.2 4.2.0
         Resolution|                            |FIXED
            Summary|[4.1 regression] rounding   |rounding problem with -
                   |problem with -fdelayed-     |fdelayed-branch on hppa/mips
                   |branch on hppa/mips         |


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


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

end of thread, other threads:[~2006-09-09 11:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-07 12:52 [Bug tree-optimization/28634] New: [4.1/4.2 regression] rounding problem with -fdelayed-branch on hppa/mips tbm at cyrius dot com
2006-08-08  0:29 ` [Bug target/28634] " pinskia at gcc dot gnu dot org
2006-08-08  0:35 ` pinskia at gcc dot gnu dot org
2006-08-13  8:34 ` [Bug rtl-optimization/28634] " rsandifo at gcc dot gnu dot org
2006-08-14 11:56 ` rsandifo at gcc dot gnu dot org
2006-08-14 11:58 ` [Bug rtl-optimization/28634] [4.1 " rsandifo at gcc dot gnu dot org
2006-09-09 10:56 ` rsandifo at gcc dot gnu dot org
2006-09-09 11:01 ` [Bug rtl-optimization/28634] " rsandifo at gcc dot gnu dot org

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).