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

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