[Bug tree-optimization/83349] New: Missed optimization in math expression: aggressive optimization with std::pow
zamazan4ik at tut dot by
gcc-bugzilla@gcc.gnu.org
Sun Dec 10 12:46:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83349
Bug ID: 83349
Summary: Missed optimization in math expression: aggressive
optimization with std::pow
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zamazan4ik at tut dot by
Target Milestone: ---
gcc(trunk) with '--std=c++17 -O3 -march=native -ffast-math' flags for this
code:
#include <cmath>
double test(double a, double x)
{
return pow(a, x) * a * a * a * a;
}
generates this assembly:
test(double, double):
sub rsp, 24
vmovsd QWORD PTR [rsp+8], xmm0
call __pow_finite
vmovsd xmm2, QWORD PTR [rsp+8]
vmulsd xmm2, xmm2, xmm2
vmulsd xmm2, xmm2, xmm2
vmulsd xmm0, xmm2, xmm0
add rsp, 24
ret
As you can see, me can simplify it by adding 4 to 'x' variable and after call
std::pow.
More information about the Gcc-bugs
mailing list