https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70777
Bug ID: 70777 Summary: x*x pessimised to pow(x,2) with -Og -ffast-math Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: suckfish at ihug dot co.nz Target Milestone: --- Compiling the function double foo(double x) { return x*x; } on x86_64 with "gcc -Og -ffast-math" converts the multiplication to a call to pow(): foo: .LFB0: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 movsd .LC0(%rip), %xmm1 call pow addq $8, %rsp .cfi_def_cfa_offset 8 ret Removing the -ffast-math or using -O/-O2/-O3 with -ffast-math, the multiplication compiles to a multiply instruction. Observed with gcc 4.8.3, 5.4.1 and 6.0.