Index: include/llvm/IR/PatternMatch.h =================================================================== --- include/llvm/IR/PatternMatch.h +++ include/llvm/IR/PatternMatch.h @@ -1602,6 +1602,16 @@ return m_Intrinsic(Op0); } +template +inline typename m_Intrinsic_Ty::Ty m_FAbs(const Opnd0 &Op0) { + return m_Intrinsic(Op0); +} + +template +inline typename m_Intrinsic_Ty::Ty m_FCanonicalize(const Opnd0 &Op0) { + return m_Intrinsic(Op0); +} + template inline typename m_Intrinsic_Ty::Ty m_FMin(const Opnd0 &Op0, const Opnd1 &Op1) { Index: lib/Transforms/InstCombine/InstCombineCalls.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCalls.cpp +++ lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2098,8 +2098,8 @@ } // fma fabs(x), fabs(x), z -> fma x, x, z - if (match(Src0, m_Intrinsic(m_Value(X))) && - match(Src1, m_Intrinsic(m_Specific(X)))) { + if (match(Src0, m_FAbs(m_Value(X))) && + match(Src1, m_FAbs(m_Specific(X)))) { II->setArgOperand(0, X); II->setArgOperand(1, X); return II; @@ -2146,7 +2146,7 @@ Value *SrcSrc; Value *Src = II->getArgOperand(0); if (match(Src, m_FNeg(m_Value(SrcSrc))) || - match(Src, m_Intrinsic(m_Value(SrcSrc)))) { + match(Src, m_FAbs(m_Value(SrcSrc)))) { // cos(-x) -> cos(x) // cos(fabs(x)) -> cos(x) II->setArgOperand(0, SrcSrc);