This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/83354] New: Missed optimization in math expression: pow(cbrt(x), y) == pow(x, y / 3)
- From: "zamazan4ik at tut dot by" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 10 Dec 2017 16:22:45 +0000
- Subject: [Bug tree-optimization/83354] New: Missed optimization in math expression: pow(cbrt(x), y) == pow(x, y / 3)
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83354
Bug ID: 83354
Summary: Missed optimization in math expression: pow(cbrt(x),
y) == pow(x, y / 3)
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 x, double y)
{
return pow(cbrt(x),y);
}
generates this assembly:
test(double, double):
sub rsp, 24
vmovsd QWORD PTR [rsp+8], xmm1
call cbrt
vmovsd xmm1, QWORD PTR [rsp+8]
add rsp, 24
jmp __pow_finite
As you can see, we can simplify it by calling pow(x, y/3). It should be faster.