[llvm] [Transforms] Add more cos combinations to SimplifyLibCalls and InstCombine (PR #79699)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 2 12:36:31 PST 2024
================
@@ -2488,11 +2488,13 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
}
case Intrinsic::cos:
case Intrinsic::amdgcn_cos: {
- Value *X;
+ Value *X, *Sign;
Value *Src = II->getArgOperand(0);
- if (match(Src, m_FNeg(m_Value(X))) || match(Src, m_FAbs(m_Value(X)))) {
- // cos(-x) -> cos(x)
- // cos(fabs(x)) -> cos(x)
+ if (match(Src, m_FNeg(m_Value(X))) || match(Src, m_FAbs(m_Value(X))) ||
+ match(Src, m_CopySign(m_Value(X), m_Value(Sign)))) {
+ // cos(-x) --> cos(x)
+ // cos(fabs(x)) --> cos(x)
+ // cos(copysign(x, y)) --> cos(x)
----------------
AtariDreams wrote:
I'll do that in another PR. I think this is good for now.
https://github.com/llvm/llvm-project/pull/79699
More information about the llvm-commits
mailing list