diff options
author | Yi Jiang <yjiang@apple.com> | 2013-12-05 22:42:50 +0000 |
---|---|---|
committer | Yi Jiang <yjiang@apple.com> | 2013-12-05 22:42:50 +0000 |
commit | 01cfa94212a1e352145319554047aea3a637d709 (patch) | |
tree | 5114ca8cd5795602b0c91191dfefd61857e1cff4 /llvm/lib | |
parent | 1251456028ec942fbd9801e15f2509a3cba51253 (diff) | |
download | bcm5719-llvm-01cfa94212a1e352145319554047aea3a637d709.tar.gz bcm5719-llvm-01cfa94212a1e352145319554047aea3a637d709.zip |
Apply transformation on OS X 10.9+ and iOS 7.0+: pow(10, x) ―> __exp10(x)
llvm-svn: 196544
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/TargetLibraryInfo.cpp | 25 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetLibraryInfo.cpp b/llvm/lib/Target/TargetLibraryInfo.cpp index 3e68fe16d4a..753562077f9 100644 --- a/llvm/lib/Target/TargetLibraryInfo.cpp +++ b/llvm/lib/Target/TargetLibraryInfo.cpp @@ -401,6 +401,31 @@ static void initialize(TargetLibraryInfo &TLI, const Triple &T, TLI.setAvailableWithName(LibFunc::fputs, "fputs$UNIX2003"); } + // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0 + // and their names are __exp10 and __exp10f. exp10l is not available on + // OS X or iOS. + if (T.isMacOSX()) { + TLI.setUnavailable(LibFunc::exp10l); + if (T.isMacOSXVersionLT(10, 9)) { + TLI.setUnavailable(LibFunc::exp10); + TLI.setUnavailable(LibFunc::exp10f); + } else { + TLI.setAvailableWithName(LibFunc::exp10, "__exp10"); + TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f"); + } + } + + if (T.getOS() == Triple::IOS) { + TLI.setUnavailable(LibFunc::exp10l); + if (T.isOSVersionLT(7, 0)) { + TLI.setUnavailable(LibFunc::exp10); + TLI.setUnavailable(LibFunc::exp10f); + } else { + TLI.setAvailableWithName(LibFunc::exp10, "__exp10"); + TLI.setAvailableWithName(LibFunc::exp10f, "__exp10f"); + } + } + // iprintf and friends are only available on XCore and TCE. if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) { TLI.setUnavailable(LibFunc::iprintf); diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 15b3e66f94a..b555cf8bddb 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -1162,6 +1162,12 @@ struct PowOpt : public UnsafeFPLibCallOptimization { hasUnaryFloatFn(TLI, Op1->getType(), LibFunc::exp2, LibFunc::exp2f, LibFunc::exp2l)) return EmitUnaryFloatFnCall(Op2, "exp2", B, Callee->getAttributes()); + // pow(10.0, x) -> exp10(x) + if (Op1C->isExactlyValue(10.0) && + hasUnaryFloatFn(TLI, Op1->getType(), LibFunc::exp10, LibFunc::exp10f, + LibFunc::exp10l)) + return EmitUnaryFloatFnCall(Op2, TLI->getName(LibFunc::exp10), B, + Callee->getAttributes()); } ConstantFP *Op2C = dyn_cast<ConstantFP>(Op2); |