diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-08-16 22:46:20 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-08-16 22:46:20 +0000 |
commit | 8ba631d9c8b5f1b4e4e314c1f4b366c58a71b4a5 (patch) | |
tree | 02dee4ae40722150a0e615fa07223949cd10da1a /llvm/lib/Transforms/Utils | |
parent | 7f9b4af1845b1cb231867c9a03fd848954155b22 (diff) | |
download | bcm5719-llvm-8ba631d9c8b5f1b4e4e314c1f4b366c58a71b4a5.tar.gz bcm5719-llvm-8ba631d9c8b5f1b4e4e314c1f4b366c58a71b4a5.zip |
[InstCombine] add reflection fold for tan(-x)
This is a follow-up suggested with rL339604.
For tan(), we don't have a corresponding LLVM
intrinsic -- unlike sin/cos -- so this is the
only way/place that we can do this fold currently.
llvm-svn: 339958
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index a0f1f8185ec..865720b416b 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -1130,16 +1130,19 @@ static Value *optimizeTrigReflections(CallInst *Call, LibFunc Func, IRBuilder<>::FastMathFlagGuard Guard(B); B.setFastMathFlags(Call->getFastMathFlags()); - // TODO: Add tan() and other calls. // TODO: Can this be shared to also handle LLVM intrinsics? Value *X; switch (Func) { case LibFunc_sin: case LibFunc_sinf: case LibFunc_sinl: + case LibFunc_tan: + case LibFunc_tanf: + case LibFunc_tanl: // sin(-X) --> -sin(X) + // tan(-X) --> -tan(X) if (match(Call->getArgOperand(0), m_OneUse(m_FNeg(m_Value(X))))) - return B.CreateFNeg(B.CreateCall(Call->getCalledFunction(), X, "sin")); + return B.CreateFNeg(B.CreateCall(Call->getCalledFunction(), X)); break; case LibFunc_cos: case LibFunc_cosf: |