Bug 11655 - [3.3 regression] long long/double -O0 produces incorrect code
Summary: [3.3 regression] long long/double -O0 produces incorrect code
Status: RESOLVED DUPLICATE of bug 323
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-24 02:24 UTC by nick
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nick 2003-07-24 02:24:52 UTC
This is a cut down version of some fp classification code.  The odd
thing is that it gets the correct answer with -O1 or with -mcpu=pentium4
-mfpmath=sse, but is incorrect at -O0.  Using 3.2.3 -O0 and -O1 both work.

the following code should print out 4094:

----
extern int printf(const char *,...);

typedef union { double d; unsigned long long ull; } doublebits;

inline int func(double x) {
    doublebits bits;
    bits.d = x;
    printf("%llu\n", bits.ull >> 51);
    return 0;
}

int main(int argc, const char **argv) {
  doublebits snan;
  snan.ull = 0x7ff0000000000001ULL;
  func(snan.d);
  return 0;
}
----

> /dept/rnd/vendor/gcc-3.3.1-20030720/bin/gcc -O0 longlong.c -o longlong
> ./longlong
4095
> /dept/rnd/vendor/gcc-3.3.1-20030720/bin/gcc -O1 longlong.c -o longlong
> ./longlong
4094
> /dept/rnd/vendor/gcc-3.3.1-20030720/bin/gcc -O0 -march=pentium4 -mfpmath=sse
longlong.c -o longlong
> ./longlong 
4094
> /dept/rnd/vendor/gcc-3.2.3/bin/gcc -O0 longlong.c -o longlong
> ./longlong
4094
Comment 1 Andrew Pinski 2003-07-24 02:40:45 UTC
This is caused by loading and then storing by the floating point registers, so this is not a bug;  It is 
the excessive precession on x86 with gcc so this is a dup of bug 323.

*** This bug has been marked as a duplicate of 323 ***