aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
diff options
context:
space:
mode:
authorDmitry Venikov <quolyk@gmail.com>2018-01-11 06:33:00 +0000
committerDmitry Venikov <quolyk@gmail.com>2018-01-11 06:33:00 +0000
commite5fbf591a7fde1e019944746d0cbc75c6cb131e4 (patch)
tree9fcd5478022fc8f171777efcb1abb0812fa228c3 /llvm/lib/Transforms/Utils/BuildLibCalls.cpp
parent0b59034b15e8b7c88b70a2523f02df045b2cc834 (diff)
downloadllvm-e5fbf591a7fde1e019944746d0cbc75c6cb131e4.zip
llvm-e5fbf591a7fde1e019944746d0cbc75c6cb131e4.tar.gz
llvm-e5fbf591a7fde1e019944746d0cbc75c6cb131e4.tar.bz2
[InstCombine] Missed optimization in math expression: sin(x) / cos(x) => tan(x)
Summary: This patch enables folding sin(x) / cos(x) -> tan(x), cos(x) / sin(x) -> 1 / tan(x) under -ffast-math flag Reviewers: hfinkel, spatel Reviewed By: spatel Subscribers: andrew.w.kaylor, efriedma, scanon, llvm-commits Differential Revision: https://reviews.llvm.org/D41286 llvm-svn: 322255
Diffstat (limited to 'llvm/lib/Transforms/Utils/BuildLibCalls.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/BuildLibCalls.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index b60dfb4..d4cf03c 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -709,6 +709,19 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
}
}
+bool llvm::hasUnaryFloatFn(const TargetLibraryInfo *TLI, Type *Ty,
+ LibFunc DoubleFn, LibFunc FloatFn,
+ LibFunc LongDoubleFn) {
+ switch (Ty->getTypeID()) {
+ case Type::FloatTyID:
+ return TLI->has(FloatFn);
+ case Type::DoubleTyID:
+ return TLI->has(DoubleFn);
+ default:
+ return TLI->has(LongDoubleFn);
+ }
+}
+
//- Emit LibCalls ------------------------------------------------------------//
Value *llvm::castToCStr(Value *V, IRBuilder<> &B) {