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
* [Bug c/44683] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
@ 2010-06-26 17:02 ` dickinsm at gmail dot com
2010-06-26 18:16 ` dickinsm at gmail dot com
` (9 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: dickinsm at gmail dot com @ 2010-06-26 17:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from dickinsm at gmail dot com 2010-06-26 17:01 -------
Created an attachment (id=21012)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21012&action=view)
Preprocessed source file
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/44683] Optimization bug with copysign builtin
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
` (8 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: dickinsm at gmail dot com @ 2010-06-26 18:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from dickinsm at gmail dot com 2010-06-26 18:16 -------
I'm also seeing this bug in gcc 4.5.0 on OS X, and it's been independently
confirmed in gcc 4.4.3 on Fedora 12 (see http://bugs.python.org/issue9069).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c/44683] Optimization bug with copysign builtin
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
` (7 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: dickinsm at gmail dot com @ 2010-06-26 18:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from dickinsm at gmail dot com 2010-06-26 18:26 -------
Apologies; I seem to have messed up the original bug report, by accidentally
pasting a slightly edited version of the original bug file. The minimal
test-case is as follows:
#include <math.h>
#include <stdio.h>
int copysign_bug(double x)
{
if (x && (x * 0.5 == x)) // note the extra "x &&" here
return 1;
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;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/44683] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
` (2 preceding siblings ...)
2010-06-26 18:26 ` dickinsm at gmail dot com
@ 2010-06-26 22:57 ` 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
` (6 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-26 22:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2010-06-26 22:57 -------
Confirmed. Somewhere during RTL opts we thread a jump the wrong way. Also
happens with SSE math.
int __attribute__((noinline,noclone))
copysign_bug (double x)
{
if (x != 0.0 && (x * 0.5 == x))
return 1;
if (__builtin_copysign(1.0, x) < 0.0)
return 2;
else
return 3;
}
int main(void)
{
double x = -0.0;
if (copysign_bug (x) != 2)
__builtin_abort ();
return 0;
}
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Component|c |rtl-optimization
Ever Confirmed|0 |1
GCC target triplet|i386-pc-solaris2.11 |i?86-*-*
Keywords| |wrong-code
Known to fail| |4.6.0
Last reconfirmed|0000-00-00 00:00:00 |2010-06-26 22:57:46
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/44683] [4.4/4.5/4.6 Regression] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
` (3 preceding siblings ...)
2010-06-26 22:57 ` [Bug rtl-optimization/44683] " rguenth at gcc dot gnu dot org
@ 2010-06-26 23:05 ` rguenth at gcc dot gnu dot org
2010-06-27 3:05 ` hjl dot tools at gmail dot com
` (5 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-26 23:05 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.3.4
Summary|Optimization bug with |[4.4/4.5/4.6 Regression]
|copysign builtin |Optimization bug with
| |copysign builtin
Target Milestone|--- |4.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/44683] [4.4/4.5/4.6 Regression] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
` (4 preceding siblings ...)
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
` (4 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-06-27 3:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from hjl dot tools at gmail dot com 2010-06-27 03:04 -------
It is caused by revision 134833:
http://gcc.gnu.org/ml/gcc-cvs/2008-04/msg01062.html
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |espindola at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/44683] [4.4/4.5/4.6 Regression] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
` (5 preceding siblings ...)
2010-06-27 3:05 ` hjl dot tools at gmail dot com
@ 2010-06-27 8:50 ` rguenth at gcc dot gnu dot org
2010-06-27 11:17 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-27 8:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2010-06-27 08:50 -------
Indeed. It's exposed by that patch.
DOM, from seeing x_2(D) != 0.0 records x_2(D) == 0.0 as equivalence. This
is not correct if signed zeros can appear.
I have a patch.
--
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
Component|rtl-optimization |tree-optimization
Last reconfirmed|2010-06-26 22:57:46 |2010-06-27 08:50:38
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/44683] [4.4/4.5/4.6 Regression] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
` (6 preceding siblings ...)
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
` (2 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-27 11:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rguenth at gcc dot gnu dot org 2010-06-27 11:16 -------
Subject: Bug 44683
Author: rguenth
Date: Sun Jun 27 11:16:46 2010
New Revision: 161467
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161467
Log:
2010-06-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44683
* tree-ssa-dom.c (record_edge_info): Record equivalences for the
false edge from the inverted condition.
* gcc.c-torture/execute/pr44683.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr44683.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-dom.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/44683] [4.4/4.5/4.6 Regression] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
` (7 preceding siblings ...)
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
10 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-27 11:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2010-06-27 11:21 -------
Subject: Bug 44683
Author: rguenth
Date: Sun Jun 27 11:21:07 2010
New Revision: 161468
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161468
Log:
2010-06-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44683
* tree-ssa-dom.c (record_edge_info): Record equivalences for the
false edge from the inverted condition.
* gcc.c-torture/execute/pr44683.c: New testcase.
Added:
branches/gcc-4_5-branch/gcc/testsuite/gcc.c-torture/execute/pr44683.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-dom.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/44683] [4.4/4.5/4.6 Regression] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
` (8 preceding siblings ...)
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
10 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-27 11:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from rguenth at gcc dot gnu dot org 2010-06-27 11:22 -------
Subject: Bug 44683
Author: rguenth
Date: Sun Jun 27 11:22:06 2010
New Revision: 161469
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161469
Log:
2010-06-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44683
* tree-ssa-dom.c (record_edge_info): Record equivalences for the
false edge from the inverted condition.
* gcc.c-torture/execute/pr44683.c: New testcase.
Added:
branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr44683.c
Modified:
branches/gcc-4_4-branch/gcc/ChangeLog
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
branches/gcc-4_4-branch/gcc/tree-ssa-dom.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44683
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/44683] [4.4/4.5/4.6 Regression] Optimization bug with copysign builtin
2010-06-26 17:00 [Bug c/44683] New: Optimization bug with copysign builtin dickinsm at gmail dot com
` (9 preceding siblings ...)
2010-06-27 11:22 ` rguenth at gcc dot gnu dot org
@ 2010-06-27 11:23 ` rguenth at gcc dot gnu dot org
10 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-06-27 11:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from rguenth at gcc dot gnu dot org 2010-06-27 11:23 -------
Fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to fail|4.6.0 |4.4.4 4.5.0
Known to work|4.3.4 |4.3.4 4.4.5 4.5.1 4.6.0
Resolution| |FIXED
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).