diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-08-13 17:40:49 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-08-13 17:40:49 +0000 |
commit | ce4ddbe96061b932e6f82a8fb6686c885332d26d (patch) | |
tree | cacc8554e1a3609da07c6e06e61fcb89177af58a /llvm/lib | |
parent | 9e4e2a2c72f24b5e110e61797b0ce9225142a238 (diff) | |
download | bcm5719-llvm-ce4ddbe96061b932e6f82a8fb6686c885332d26d.tar.gz bcm5719-llvm-ce4ddbe96061b932e6f82a8fb6686c885332d26d.zip |
[SimplifyLibCalls] reduce code for optimizeCos; NFCI
llvm-svn: 339588
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 2a9da59a6e9..6636f71a6d4 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -1124,18 +1124,17 @@ Value *LibCallSimplifier::optimizeCAbs(CallInst *CI, IRBuilder<> &B) { Value *LibCallSimplifier::optimizeCos(CallInst *CI, IRBuilder<> &B) { Function *Callee = CI->getCalledFunction(); - Value *Ret = nullptr; StringRef Name = Callee->getName(); if (UnsafeFPShrink && Name == "cos" && hasFloatVersion(Name)) - Ret = optimizeUnaryDoubleFP(CI, B, true); + if (Value *V = optimizeUnaryDoubleFP(CI, B, true)) + return V; - // cos(-x) -> cos(x) - Value *Op1 = CI->getArgOperand(0); - if (BinaryOperator::isFNeg(Op1)) { - BinaryOperator *BinExpr = cast<BinaryOperator>(Op1); - return B.CreateCall(Callee, BinExpr->getOperand(1), "cos"); - } - return Ret; + // cos(-X) -> cos(X) + Value *X; + if (match(CI->getArgOperand(0), m_FNeg(m_Value(X)))) + return B.CreateCall(Callee, X, "cos"); + + return nullptr; } static Value *getPow(Value *InnerChain[33], unsigned Exp, IRBuilder<> &B) { |