[cfe-dev] Clang not generating pow_finite with -ffast-math
Murali, Sriram
sriram.murali at intel.com
Fri Sep 13 13:42:20 PDT 2013
Hi,
I am trying to make clang generate code similar to gcc for the following function with –ffast-math option.
#include <cmath>
double foo(double val, double i) {
double t = log(exp(val));
return pow(t, i);
}
There are a few issues here.
· Firstly, clang is not optimizing log(exp(val)) away into val.
· Secondly, clang is calling an choosing an intrinsic of pow, instead of a library call to @__pow_finite
%0 = tail call double @llvm.pow.f64(double %call1, double %i)
I am wondering if there is a performance benefit in using @llvm.pow.f64, because at the end of the day, llvm generates code for x86 as follows:
.cfi_def_cfa_offset 16
movsd %xmm1, (%rsp) # 8-byte Spill
callq __exp_finite
callq __log_finite
movsd (%rsp), %xmm1 # 8-byte Reload
popq %rax
jmp pow
I believe __pow_finite is faster than pow. Please correct me if I am wrong.
Thanks
Ram
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130913/227ba0eb/attachment.html>
More information about the cfe-dev
mailing list