[llvm-bugs] [Bug 35605] New: Missed optimization in math expression: pow(cbrt(x), y) == pow(x, y / 3)
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Dec 10 08:20:55 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35605
Bug ID: 35605
Summary: Missed optimization in math expression: pow(cbrt(x),
y) == pow(x, y / 3)
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: zamazan4ik at tut.by
CC: llvm-bugs at lists.llvm.org
clang(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): # @test(double, double)
push rax
vmovsd qword ptr [rsp], xmm1 # 8-byte Spill
call cbrt
vmovsd xmm1, qword ptr [rsp] # 8-byte Reload
pop rax
jmp pow # TAILCALL
As you can see, we can simplify it by calling pow(x, y/3). It should be faster.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171210/3c77f0c2/attachment.html>
More information about the llvm-bugs
mailing list