[SimplifyLibCalls] Tranform log(pow(x, y)) -> y*log(x).
authorDavide Italiano <davide@freebsd.org>
Sun, 29 Nov 2015 20:58:04 +0000 (20:58 +0000)
committerDavide Italiano <davide@freebsd.org>
Sun, 29 Nov 2015 20:58:04 +0000 (20:58 +0000)
commit0f019d6283f8819771a3bc164320abb5d09df8f1
treeba57b7b2a62fb75325cea5b16e62a9fd51ff75ac
parent173327b7af38d294ff8fa7f77ed3a1c68f84a24c
[SimplifyLibCalls] Tranform log(pow(x, y)) -> y*log(x).

This one is enabled only under -ffast-math. There are cases where the
difference between the value computed and the correct value is huge
even for ffast-math, e.g. as Steven pointed out:

x = -1, y = -4
log(pow(-1), 4) = 0
4*log(-1) = NaN

I checked what GCC does and apparently they do the same optimization
(which result in the dramatic difference). Future work might try to
make this (slightly) less worse.

Differential Revision: http://reviews.llvm.org/D14400

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254263 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Utils/SimplifyLibCalls.h
lib/Transforms/Utils/SimplifyLibCalls.cpp
test/Transforms/InstCombine/log-pow-nofastmath.ll [new file with mode: 0644]
test/Transforms/InstCombine/log-pow.ll [new file with mode: 0644]