public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/43783]  New: [4.5 regression] -O -ftree-pre options compile libbid wrong
@ 2010-04-18 15:53 roman at binarylife dot net
  2010-04-18 18:22 ` [Bug tree-optimization/43783] " rguenth at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: roman at binarylife dot net @ 2010-04-18 15:53 UTC (permalink / raw)
  To: gcc-bugs

$ cat test.c
#include <stdio.h>
int main() {
  _Decimal128 const a=1.111111111111111111111111111111111dl;
  _Decimal128 const b=1.1111111e-6158dl;
  _Decimal128 volatile x=a;
  _Decimal128 volatile y=b;
  double ab=a*b*1.0e6000dl;
  double xy=x*y*1.0e6000dl;
  printf("ab=%g\n",ab);
  printf("xy=%g\n",xy);
}

$ gcc test.c && ./a.out
ab=9.64506e-159
xy=9.64506e-159

$ gcc -O test.c && ./a.out
ab=1.23457e-158
xy=9.64506e-159

$ gcc --version | head -1
gcc (GCC) 4.5.1 20100418 (prerelease)

The correct value is 1.23457e-158:

$ echo "1.111111111111111111111111111111111*1.1111111" | bc
1.234567888888888888888888888888888

A simple modification of test.c can show that it is x*y and a*b, when computed
by libbid, are incorrect. The a*b expression, when computed by gcc (with -O),
is correct.

To further diagnose, I extracted libbid from the gcc source tree and compiled
it outside of gcc to link it with the above test.c program. I added some
#defines to compile the library and renamed some functions to call them
directly from the test.

I found that if compiled with -O only, libbid multiplies correctly. With -O
-ftree-pre, it multiplies incorrectly.

The real job is done by bid128_ext_fma() (about 3000 C lines).


-- 
           Summary: [4.5 regression] -O -ftree-pre options compile libbid
                    wrong
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: roman at binarylife dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


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

* [Bug tree-optimization/43783] [4.5 regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
@ 2010-04-18 18:22 ` rguenth at gcc dot gnu dot org
  2010-04-18 18:34 ` roman at binarylife dot net
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-18 18:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-04-18 18:22 -------
This needs a testcase.  The libdecnumber code is a mess (and I can't find
an implementation for bid128_ext_fma()).


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Target Milestone|---                         |4.5.1


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


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

* [Bug tree-optimization/43783] [4.5 regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
  2010-04-18 18:22 ` [Bug tree-optimization/43783] " rguenth at gcc dot gnu dot org
@ 2010-04-18 18:34 ` roman at binarylife dot net
  2010-04-19  4:25 ` roman at binarylife dot net
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: roman at binarylife dot net @ 2010-04-18 18:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from roman at binarylife dot net  2010-04-18 18:34 -------
(In reply to comment #1)
> This needs a testcase.  The libdecnumber code is a mess (and I can't find
> an implementation for bid128_ext_fma()).
> 

bid128_ext_fma() is in libgcc/config/libbid/bid128_fma.c


-- 


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


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

* [Bug tree-optimization/43783] [4.5 regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
  2010-04-18 18:22 ` [Bug tree-optimization/43783] " rguenth at gcc dot gnu dot org
  2010-04-18 18:34 ` roman at binarylife dot net
@ 2010-04-19  4:25 ` roman at binarylife dot net
  2010-04-19  9:56 ` [Bug tree-optimization/43783] [4.5/4.6 " rguenth at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: roman at binarylife dot net @ 2010-04-19  4:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from roman at binarylife dot net  2010-04-19 04:25 -------
Starting from r150519 gcc compiles its own internal libbid wrong.

With the previous revision of gcc, the output of the above test.c is correct:

$ gcc -O test.c && ./a.out
ab=1.23457e-158
xy=1.23457e-158


-- 


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


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

* [Bug tree-optimization/43783] [4.5/4.6 regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
                   ` (2 preceding siblings ...)
  2010-04-19  4:25 ` roman at binarylife dot net
@ 2010-04-19  9:56 ` rguenth at gcc dot gnu dot org
  2010-04-19 11:03 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-19  9:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2010-04-19 09:56 -------
Confirmed (libbid result is incorrect, GCC constant-folded result is correct).


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to work|                            |4.4.3
   Last reconfirmed|0000-00-00 00:00:00         |2010-04-19 09:56:21
               date|                            |
            Summary|[4.5 regression] -O -ftree- |[4.5/4.6 regression] -O -
                   |pre options compile libbid  |ftree-pre options compile
                   |wrong                       |libbid wrong


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


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

* [Bug tree-optimization/43783] [4.5/4.6 regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
                   ` (3 preceding siblings ...)
  2010-04-19  9:56 ` [Bug tree-optimization/43783] [4.5/4.6 " rguenth at gcc dot gnu dot org
@ 2010-04-19 11:03 ` rguenth at gcc dot gnu dot org
  2010-04-19 11:20 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-19 11:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2010-04-19 11:02 -------
It's not bid128_ext_fma that is miscompiled but bid_round.c, building that
with -O1 [-ftree-pre] works [fails].

__bid_round192_39_57 is miscompiled by PRE.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-04-19 09:56:21         |2010-04-19 11:02:59
               date|                            |


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


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

* [Bug tree-optimization/43783] [4.5/4.6 regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
                   ` (4 preceding siblings ...)
  2010-04-19 11:03 ` rguenth at gcc dot gnu dot org
@ 2010-04-19 11:20 ` rguenth at gcc dot gnu dot org
  2010-04-19 11:57 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-19 11:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2010-04-19 11:20 -------
Testcase:

typedef __attribute__((aligned(16)))
struct {
    unsigned long w[3];
} UINT192;

UINT192 __bid_Kx192[32];

extern void abort (void);

int main()
{
  int i = 0;
  unsigned long x = 0;
  for (i = 0; i < 32; ++i)
    __bid_Kx192[i].w[1] = i == 1;
  for (i = 0; i < 32; ++i)
    x += __bid_Kx192[1].w[1];
  if (x != 32)
    abort ();
  return 0;
}


-- 


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


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

* [Bug tree-optimization/43783] [4.5/4.6 regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
                   ` (5 preceding siblings ...)
  2010-04-19 11:20 ` rguenth at gcc dot gnu dot org
@ 2010-04-19 11:57 ` rguenth at gcc dot gnu dot org
  2010-04-19 13:37 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-19 11:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2010-04-19 11:57 -------
The array element alignment is not properly visible, but instead loads of
random crap alignments appear in trees.


-- 


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


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

* [Bug tree-optimization/43783] [4.5/4.6 regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
                   ` (6 preceding siblings ...)
  2010-04-19 11:57 ` rguenth at gcc dot gnu dot org
@ 2010-04-19 13:37 ` rguenth at gcc dot gnu dot org
  2010-04-19 20:46 ` [Bug tree-optimization/43783] [4.5 Regression] " roman at binarylife dot net
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-19 13:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from rguenth at gcc dot gnu dot org  2010-04-19 13:37 -------
Subject: Bug 43783

Author: rguenth
Date: Mon Apr 19 13:36:54 2010
New Revision: 158517

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158517
Log:
2010-04-19  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/43783
        * tree-ssa-pre.c (create_component_ref_by_pieces_1): Drop
        constant ARRAY_REF operands two and three if possible.

        * gcc.c-torture/execute/pr43783.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr43783.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-pre.c


-- 


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


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

* [Bug tree-optimization/43783] [4.5 Regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
                   ` (7 preceding siblings ...)
  2010-04-19 13:37 ` rguenth at gcc dot gnu dot org
@ 2010-04-19 20:46 ` roman at binarylife dot net
  2010-04-20  9:06 ` rguenth at gcc dot gnu dot org
  2010-04-20  9:06 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: roman at binarylife dot net @ 2010-04-19 20:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from roman at binarylife dot net  2010-04-19 20:46 -------
The 4.5 branch works for me if patched this way.
Thanks.


-- 


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


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

* [Bug tree-optimization/43783] [4.5 Regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
                   ` (8 preceding siblings ...)
  2010-04-19 20:46 ` [Bug tree-optimization/43783] [4.5 Regression] " roman at binarylife dot net
@ 2010-04-20  9:06 ` rguenth at gcc dot gnu dot org
  2010-04-20  9:06 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-20  9:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2010-04-20 09:05 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

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


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


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

* [Bug tree-optimization/43783] [4.5 Regression] -O -ftree-pre options compile libbid wrong
  2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
                   ` (9 preceding siblings ...)
  2010-04-20  9:06 ` rguenth at gcc dot gnu dot org
@ 2010-04-20  9:06 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-20  9:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from rguenth at gcc dot gnu dot org  2010-04-20 09:05 -------
Subject: Bug 43783

Author: rguenth
Date: Tue Apr 20 09:05:33 2010
New Revision: 158549

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158549
Log:
2010-04-20  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/43783
        * tree-ssa-pre.c (create_component_ref_by_pieces_1): Drop
        constant ARRAY_REF operands two and three if possible.

        * gcc.c-torture/execute/pr43783.c: New testcase.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.c-torture/execute/pr43783.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_5-branch/gcc/tree-ssa-pre.c


-- 


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


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

end of thread, other threads:[~2010-04-20  9:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-18 15:53 [Bug tree-optimization/43783] New: [4.5 regression] -O -ftree-pre options compile libbid wrong roman at binarylife dot net
2010-04-18 18:22 ` [Bug tree-optimization/43783] " rguenth at gcc dot gnu dot org
2010-04-18 18:34 ` roman at binarylife dot net
2010-04-19  4:25 ` roman at binarylife dot net
2010-04-19  9:56 ` [Bug tree-optimization/43783] [4.5/4.6 " rguenth at gcc dot gnu dot org
2010-04-19 11:03 ` rguenth at gcc dot gnu dot org
2010-04-19 11:20 ` rguenth at gcc dot gnu dot org
2010-04-19 11:57 ` rguenth at gcc dot gnu dot org
2010-04-19 13:37 ` rguenth at gcc dot gnu dot org
2010-04-19 20:46 ` [Bug tree-optimization/43783] [4.5 Regression] " roman at binarylife dot net
2010-04-20  9:06 ` rguenth at gcc dot gnu dot org
2010-04-20  9:06 ` rguenth 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).