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.