public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44683]  New: Optimization bug with copysign builtin
@ 2010-06-26 17:00 dickinsm at gmail dot com
  2010-06-26 17:02 ` [Bug c/44683] " dickinsm at gmail dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: dickinsm at gmail dot com @ 2010-06-26 17:00 UTC (permalink / raw)
  To: gcc-bugs

Here's a minimal test-case:

---------


int copysign_bug(double x)
{
  if (x * 0.5 == x)
    return 1;
  else if (copysign(1.0, x) < 0.0)
    return 2;
  else
    return 3;
}

int main(void) {
  double x;
  x = -0.0;
  printf("copysign_bug(%.17g) = %d\n", x, copysign_bug(x));

  x = 0.0;
  printf("copysign_bug(%.17g) = %d\n", x, copysign_bug(x));

  return 0;
}

-------

I'm compiling and executing the above code (filename copysign_bug.c) on
OpenSolaris build snv_134 running in Parallels on a Macbook Pro (Intel Core 2
Duo), using the following command line:

gcc-4.4 -m64 -fno-inline -g -O3 copysign_bug.c -o copysign_bug &&
./copysign_bug

I get the results:

copysign_bug(-0) = 3
copysign_bug(0) = 3

I was expecting to see the results:

copysign_bug(-0) = 2
copysign_bug(0) = 3

I get the latter results if I omit the '-O3' flag, or if I compile with
-fno-builtin-copysign and link with the math library.

gcc build information:

dickinsm@eratosthenes:~/trunk$ gcc-4.4 -v -save-temps -m64 -lm
-fno-builtin-copysign -fno-inline -g copysign_bug.c
Using built-in specs.
Target: i386-pc-solaris2.11
Configured with: ../gcc-4.4.4/configure --prefix=/usr/local
--program-suffix=-4.4 --with-mpfr-include=/usr/include/mpfr
--with-gmp-include=/usr/include/gmp --with-as=/usr/bin/gas --with-gnu-as
--with-ld=/usr/bin/ld --without-gnu-ld --enable-shared --enable-multilib
--enable-languages=c,c++,objc
Thread model: posix
gcc version 4.4.4 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-m64' '-fno-builtin-copysign'
'-fno-inline' '-g' '-mtune=generic'
 /usr/local/libexec/gcc/i386-pc-solaris2.11/4.4.4/cc1 -E -quiet -v -imultilib
amd64 copysign_bug.c -m64 -mtune=generic -fno-builtin-copysign -fno-inline -g
-fworking-directory -fpch-preprocess -o copysign_bug.i
ignoring nonexistent directory
"/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../i386-pc-solaris2.11/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/include
 /usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-m64' '-fno-builtin-copysign'
'-fno-inline' '-g' '-mtune=generic'
 /usr/local/libexec/gcc/i386-pc-solaris2.11/4.4.4/cc1 -fpreprocessed
copysign_bug.i -quiet -dumpbase copysign_bug.c -m64 -mtune=generic -auxbase
copysign_bug -g -version -fno-builtin-copysign -fno-inline -o copysign_bug.s
GNU C (GCC) version 4.4.4 (i386-pc-solaris2.11)
        compiled by GNU C version 4.4.4, GMP version 4.3.1, MPFR version
2.4.1-p5.
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=131015
Compiler executable checksum: f408a824c22e56e60b321448197fb865
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-m64' '-fno-builtin-copysign'
'-fno-inline' '-g' '-mtune=generic'
 /usr/bin/gas -v -V -Qy --64 -s -o copysign_bug.o copysign_bug.s
GNU assembler version 2.19 (i386-pc-solaris2.11) using BFD version (GNU
Binutils) 2.19
COMPILER_PATH=/usr/local/libexec/gcc/i386-pc-solaris2.11/4.4.4/:/usr/local/libexec/gcc/i386-pc-solaris2.11/4.4.4/:/usr/local/libexec/gcc/i386-pc-solaris2.11/:/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/:/usr/local/lib/gcc/i386-pc-solaris2.11/:/usr/ccs/bin/
LIBRARY_PATH=/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/amd64/:/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../amd64/:/lib/amd64/:/usr/lib/amd64/:/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/:/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-m64' '-fno-builtin-copysign'
'-fno-inline' '-g' '-mtune=generic'
 /usr/local/libexec/gcc/i386-pc-solaris2.11/4.4.4/collect2 -V -Y
P,/lib/64:/usr/lib/64 -Qy /usr/lib/amd64/crt1.o /usr/lib/amd64/crti.o
/usr/lib/amd64/values-Xa.o
/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/amd64/crtbegin.o
-L/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/amd64
-L/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../amd64 -L/lib/amd64
-L/usr/lib/amd64 -L/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4
-L/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/../../.. -lm copysign_bug.o
-lgcc -lgcc_eh -lc -lgcc -lgcc_eh
/usr/local/lib/gcc/i386-pc-solaris2.11/4.4.4/amd64/crtend.o
/usr/lib/amd64/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1689


-- 
           Summary: Optimization bug with copysign builtin
           Product: gcc
           Version: 4.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dickinsm at gmail dot com
 GCC build triplet: i386-pc-solaris2.11
  GCC host triplet: i386-pc-solaris2.11
GCC target triplet: i386-pc-solaris2.11


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


^ permalink raw reply	[flat|nested] 14+ messages in thread
[parent not found: <bug-44683-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2011-10-23 15:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
2010-06-26 17:02 ` [Bug c/44683] " dickinsm at gmail dot com
2010-06-26 18:16 ` dickinsm at gmail dot com
2010-06-26 18:26 ` dickinsm at gmail dot com
2010-06-26 22:57 ` [Bug rtl-optimization/44683] " rguenth at gcc dot gnu dot org
2010-06-26 23:05 ` [Bug rtl-optimization/44683] [4.4/4.5/4.6 Regression] " rguenth at gcc dot gnu dot org
2010-06-27  3:05 ` hjl dot tools at gmail dot com
2010-06-27  8:50 ` [Bug tree-optimization/44683] " rguenth at gcc dot gnu dot org
2010-06-27 11:17 ` rguenth at gcc dot gnu dot org
2010-06-27 11:21 ` rguenth at gcc dot gnu dot org
2010-06-27 11:22 ` rguenth at gcc dot gnu dot org
2010-06-27 11:23 ` rguenth at gcc dot gnu dot org
     [not found] <bug-44683-4@http.gcc.gnu.org/bugzilla/>
2011-10-22 16:58 ` ebotcazou at gcc dot gnu.org
2011-10-23 15:58 ` ebotcazou at gcc dot gnu.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).