aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorMichael Kuperstein <michael.m.kuperstein@intel.com>2013-08-19 06:55:47 +0000
committerMichael Kuperstein <michael.m.kuperstein@intel.com>2013-08-19 06:55:47 +0000
commit2063637fa7c9ebc880cf858674eb45727d4ea295 (patch)
treecd592484d3021840d068faf0e36e852ef0bf7c53 /lib/Transforms/Utils
parenta0e735ee16f439675c1842e47ba3149aa226bdc0 (diff)
downloadexternal_llvm-2063637fa7c9ebc880cf858674eb45727d4ea295.zip
external_llvm-2063637fa7c9ebc880cf858674eb45727d4ea295.tar.gz
external_llvm-2063637fa7c9ebc880cf858674eb45727d4ea295.tar.bz2
Adds missing TLI check for library simplification of
* pow(x, 0.5) -> fabs(sqrt(x)) * pow(2.0, x) -> exp2(x) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/SimplifyLibCalls.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/SimplifyLibCalls.cpp b/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 93720be..ff0d5d9 100644
--- a/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1133,9 +1133,11 @@ struct PowOpt : public UnsafeFPLibCallOptimization {
Value *Op1 = CI->getArgOperand(0), *Op2 = CI->getArgOperand(1);
if (ConstantFP *Op1C = dyn_cast<ConstantFP>(Op1)) {
- if (Op1C->isExactlyValue(1.0)) // pow(1.0, x) -> 1.0
+ // pow(1.0, x) -> 1.0
+ if (Op1C->isExactlyValue(1.0))
return Op1C;
- if (Op1C->isExactlyValue(2.0)) // pow(2.0, x) -> exp2(x)
+ // pow(2.0, x) -> exp2(x)
+ if (Op1C->isExactlyValue(2.0) && TLI->has(LibFunc::exp2))
return EmitUnaryFloatFnCall(Op2, "exp2", B, Callee->getAttributes());
}
@@ -1145,7 +1147,8 @@ struct PowOpt : public UnsafeFPLibCallOptimization {
if (Op2C->getValueAPF().isZero()) // pow(x, 0.0) -> 1.0
return ConstantFP::get(CI->getType(), 1.0);
- if (Op2C->isExactlyValue(0.5)) {
+ if (Op2C->isExactlyValue(0.5) &&
+ TLI->has(LibFunc::sqrt) && TLI->has(LibFunc::fabs)) {
// Expand pow(x, 0.5) to (x == -infinity ? +infinity : fabs(sqrt(x))).
// This is faster than calling pow, and still handles negative zero
// and negative infinity correctly.