public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/21067] New: Excessive optimization of floating point expression
@ 2005-04-17 7:23 bagnara at cs dot unipr dot it
2005-04-17 7:34 ` [Bug middle-end/21067] " pinskia at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: bagnara at cs dot unipr dot it @ 2005-04-17 7:23 UTC (permalink / raw)
To: gcc-bugs
Compiling the following with GCC 3.4.3 (with "gcc -O2 -S file.c")
float mul2(float a, float b) {
float v = -a * b;
return -v;
}
produce the erroneous code
pushl %ebp
movl %esp, %ebp
flds 8(%ebp)
fmuls 12(%ebp)
popl %ebp
ret
where the sign changes have been erroneously elided.
Notice that, depending on the rounding mode in effect,
this produces the wrong results.
Strangely enough, the code produced for
float div2(float a, float b) {
float v = -a / b;
return -v;
}
is instead correct.
--
Summary: Excessive optimization of floating point expression
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bagnara at cs dot unipr dot it
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21067
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/21067] Excessive optimization of floating point expression
2005-04-17 7:23 [Bug middle-end/21067] New: Excessive optimization of floating point expression bagnara at cs dot unipr dot it
@ 2005-04-17 7:34 ` pinskia at gcc dot gnu dot org
2005-04-17 8:52 ` bagnara at cs dot unipr dot it
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-17 7:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-17 07:34 -------
Note GCC does not know about the rounding mode, in fact the round mode is only changeable in C99
by the #pragma which GCC does not do right now and I thought that is a different PR already.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21067
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/21067] Excessive optimization of floating point expression
2005-04-17 7:23 [Bug middle-end/21067] New: Excessive optimization of floating point expression bagnara at cs dot unipr dot it
2005-04-17 7:34 ` [Bug middle-end/21067] " pinskia at gcc dot gnu dot org
@ 2005-04-17 8:52 ` bagnara at cs dot unipr dot it
2005-06-15 16:42 ` vincent at vinc17 dot org
2005-06-15 16:43 ` vincent at vinc17 dot org
3 siblings, 0 replies; 5+ messages in thread
From: bagnara at cs dot unipr dot it @ 2005-04-17 8:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bagnara at cs dot unipr dot it 2005-04-17 08:52 -------
Subject: Re: Excessive optimization of floating point
expression
pinskia at gcc dot gnu dot org wrote:
> Note GCC does not know about the rounding mode,
This seems a good reason not to attempt optimizations
that only work with a given rounding mode.
> in fact the round mode is only changeable in C99
> by the #pragma which GCC does not do right now and I thought that is a different PR already.
I do not see the connection with the #pragma you are talking about.
IMHO, a program that uses the services of <fenv.h>, which is
covered by section 7.6 of the C99 standard, is a perfectly
legal C99 program, and thus deserves to be compiled correctly
as prescribed by that standard.
Am I missing something?
All the best,
Roberto
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21067
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/21067] Excessive optimization of floating point expression
2005-04-17 7:23 [Bug middle-end/21067] New: Excessive optimization of floating point expression bagnara at cs dot unipr dot it
2005-04-17 7:34 ` [Bug middle-end/21067] " pinskia at gcc dot gnu dot org
2005-04-17 8:52 ` bagnara at cs dot unipr dot it
@ 2005-06-15 16:42 ` vincent at vinc17 dot org
2005-06-15 16:43 ` vincent at vinc17 dot org
3 siblings, 0 replies; 5+ messages in thread
From: vincent at vinc17 dot org @ 2005-06-15 16:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From vincent at vinc17 dot org 2005-06-15 16:42 -------
Even without <fenv.h>, the function could be in a library called in a directed
rounding mode.
And one can change the rounding mode via a standard function in the glibc, no
need for a pragma.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21067
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/21067] Excessive optimization of floating point expression
2005-04-17 7:23 [Bug middle-end/21067] New: Excessive optimization of floating point expression bagnara at cs dot unipr dot it
` (2 preceding siblings ...)
2005-06-15 16:42 ` vincent at vinc17 dot org
@ 2005-06-15 16:43 ` vincent at vinc17 dot org
3 siblings, 0 replies; 5+ messages in thread
From: vincent at vinc17 dot org @ 2005-06-15 16:43 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |vincent at vinc17 dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21067
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-06-15 16:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-17 7:23 [Bug middle-end/21067] New: Excessive optimization of floating point expression bagnara at cs dot unipr dot it
2005-04-17 7:34 ` [Bug middle-end/21067] " pinskia at gcc dot gnu dot org
2005-04-17 8:52 ` bagnara at cs dot unipr dot it
2005-06-15 16:42 ` vincent at vinc17 dot org
2005-06-15 16:43 ` vincent at vinc17 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).