public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/29538] New: Incorrect interpretation of floating-point unary minus
@ 2006-10-21 18:05 guillaume dot melquiond at ens-lyon dot fr
2006-10-21 18:19 ` [Bug target/29538] " rguenth at gcc dot gnu dot org
2006-10-21 20:17 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: guillaume dot melquiond at ens-lyon dot fr @ 2006-10-21 18:05 UTC (permalink / raw)
To: gcc-bugs
Testcase:
void f(float);
void g(double x) { f(-x); }
Using -fdump-tree-original shows that GCC understands the above code as
"f(-(float)x)", although it should really be "f((float)(-x))". As a
consequence, the generated code is not efficient (on x86), as GCC will have to
store x to memory as a float before loading it again and changing its sign.
Moreover, the computed value is not the expected one when the rounding mode is
a directed rounding, as the conversion happens before the sign change.
Tested with Debian GCC 3.3.6, 3.4.6, 4.0.4, and 4.1.2. Version 3.3 generates
the correct code, the other ones don't.
--
Summary: Incorrect interpretation of floating-point unary minus
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: guillaume dot melquiond at ens-lyon dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29538
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/29538] Incorrect interpretation of floating-point unary minus
2006-10-21 18:05 [Bug c/29538] New: Incorrect interpretation of floating-point unary minus guillaume dot melquiond at ens-lyon dot fr
@ 2006-10-21 18:19 ` rguenth at gcc dot gnu dot org
2006-10-21 20:17 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-10-21 18:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2006-10-21 18:19 -------
Unary negation does not affect rounding, so I fail to see how it shall matter
what type the negation is done on.
It is true that for x87 math the -(float)x sequence is slower:
g:
pushl %ebp
movl %esp, %ebp
subl $4, %esp
fldl 8(%ebp)
fstps -4(%ebp)
flds -4(%ebp)
fchs
fstps 8(%ebp)
leave
jmp f
so, confirmed as missed-optimization.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Component|c |target
Ever Confirmed|0 |1
GCC target triplet| |i?86-*-*
Keywords| |missed-optimization
Last reconfirmed|0000-00-00 00:00:00 |2006-10-21 18:19:02
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29538
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/29538] Incorrect interpretation of floating-point unary minus
2006-10-21 18:05 [Bug c/29538] New: Incorrect interpretation of floating-point unary minus guillaume dot melquiond at ens-lyon dot fr
2006-10-21 18:19 ` [Bug target/29538] " rguenth at gcc dot gnu dot org
@ 2006-10-21 20:17 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-21 20:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-10-21 20:17 -------
Though minus cannot change the rounding but the rounding mode can be different
for rounding from double to float in that we could have a negative number with
round towards zero which causes us to get different answers. Now the default
rounding we are fine.
*** This bug has been marked as a duplicate of 21032 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29538
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-21 20:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-21 18:05 [Bug c/29538] New: Incorrect interpretation of floating-point unary minus guillaume dot melquiond at ens-lyon dot fr
2006-10-21 18:19 ` [Bug target/29538] " rguenth at gcc dot gnu dot org
2006-10-21 20:17 ` pinskia 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).