[llvm-bugs] [Bug 35742] New: Missed optimization in math expression: log of pow or exp of log
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Dec 24 16:06:44 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35742
Bug ID: 35742
Summary: Missed optimization in math expression: log of pow or
exp of log
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: zheltonozhskiy at gmail.com
CC: llvm-bugs at lists.llvm.org
#include <cmath>
double f(double a)
{
return exp(log(a)) ;
}
double f2(double a, double b)
{
return log(pow(a,b)) ;
}
clang(trunk) -g0 -O3 -march=bdver4 -ffast-math generates following assembly:
f(double): # @f(double)
pushq %rax
callq log
popq %rax
jmp exp # TAILCALL
f2(double, double): # @f2(double, double)
pushq %rax
callq pow
popq %rax
jmp log # TAILCALL
While gcc generates
f(double):
ret
f2(double, double):
subq $24, %rsp
vmovsd %xmm1, 8(%rsp)
call __log_finite
vmovsd 8(%rsp), %xmm1
addq $24, %rsp
vmulsd %xmm0, %xmm1, %xmm0
ret
replacing exponent of natural logarithm with the number itself and ln(a^b) with
b*ln(a) (same for log10/log2)
--
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/20171225/d5b8210d/attachment.html>
More information about the llvm-bugs
mailing list