public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111221] New: Floating point handling a*1.0 vs. a+0.0
@ 2023-08-29 5:54 tkoenig at gcc dot gnu.org
2023-08-29 6:00 ` [Bug tree-optimization/111221] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2023-08-29 5:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111221
Bug ID: 111221
Summary: Floating point handling a*1.0 vs. a+0.0
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: tkoenig at gcc dot gnu.org
Target Milestone: ---
I just noticed that gcc will optimize away multiplying a floating
point number with 1.0, but will not do for an addition with 0.0.
Example, with -O3,
double add0 (double a)
{
return a + 0.0;
}
double mul1 (double a)
{
return a * 1.0;
}
yields
add0:
.LFB0:
.cfi_startproc
pxor %xmm1, %xmm1
addsd %xmm1, %xmm0
ret
vs.
mul1:
.LFB1:
.cfi_startproc
ret
which seems inconsistent. If this is the result of a deliberate design
decision, feel free to close as WONTFIX.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/111221] Floating point handling a*1.0 vs. a+0.0
2023-08-29 5:54 [Bug tree-optimization/111221] New: Floating point handling a*1.0 vs. a+0.0 tkoenig at gcc dot gnu.org
@ 2023-08-29 6:00 ` pinskia at gcc dot gnu.org
2023-08-29 6:01 ` pinskia at gcc dot gnu.org
2023-08-29 9:56 ` xry111 at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-29 6:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111221
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-0.0 * 1.0 is still -0.0
While -0.0 + 0.0 is 0.0 rather than -0.0.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/111221] Floating point handling a*1.0 vs. a+0.0
2023-08-29 5:54 [Bug tree-optimization/111221] New: Floating point handling a*1.0 vs. a+0.0 tkoenig at gcc dot gnu.org
2023-08-29 6:00 ` [Bug tree-optimization/111221] " pinskia at gcc dot gnu.org
@ 2023-08-29 6:01 ` pinskia at gcc dot gnu.org
2023-08-29 9:56 ` xry111 at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-29 6:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111221
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
That is GCC will remove additions of -0.0:
double addneg0 (double a)
{
return a + -0.0;
}
Gets optimized to just `return a;`.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/111221] Floating point handling a*1.0 vs. a+0.0
2023-08-29 5:54 [Bug tree-optimization/111221] New: Floating point handling a*1.0 vs. a+0.0 tkoenig at gcc dot gnu.org
2023-08-29 6:00 ` [Bug tree-optimization/111221] " pinskia at gcc dot gnu.org
2023-08-29 6:01 ` pinskia at gcc dot gnu.org
@ 2023-08-29 9:56 ` xry111 at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-08-29 9:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111221
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
FWIW if you want "add0" to be optimized use -fno-signed-zeros.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-29 9:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-29 5:54 [Bug tree-optimization/111221] New: Floating point handling a*1.0 vs. a+0.0 tkoenig at gcc dot gnu.org
2023-08-29 6:00 ` [Bug tree-optimization/111221] " pinskia at gcc dot gnu.org
2023-08-29 6:01 ` pinskia at gcc dot gnu.org
2023-08-29 9:56 ` xry111 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).