[llvm] r338111 - PatternMatch: Add wrappers for fabs and canonicalize
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 27 02:04:36 PDT 2018
Author: arsenm
Date: Fri Jul 27 02:04:35 2018
New Revision: 338111
URL: http://llvm.org/viewvc/llvm-project?rev=338111&view=rev
Log:
PatternMatch: Add wrappers for fabs and canonicalize
Modified:
llvm/trunk/include/llvm/IR/PatternMatch.h
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
Modified: llvm/trunk/include/llvm/IR/PatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PatternMatch.h?rev=338111&r1=338110&r2=338111&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/PatternMatch.h (original)
+++ llvm/trunk/include/llvm/IR/PatternMatch.h Fri Jul 27 02:04:35 2018
@@ -1602,6 +1602,16 @@ inline typename m_Intrinsic_Ty<Opnd0>::T
return m_Intrinsic<Intrinsic::bswap>(Op0);
}
+template <typename Opnd0>
+inline typename m_Intrinsic_Ty<Opnd0>::Ty m_FAbs(const Opnd0 &Op0) {
+ return m_Intrinsic<Intrinsic::fabs>(Op0);
+}
+
+template <typename Opnd0>
+inline typename m_Intrinsic_Ty<Opnd0>::Ty m_FCanonicalize(const Opnd0 &Op0) {
+ return m_Intrinsic<Intrinsic::canonicalize>(Op0);
+}
+
template <typename Opnd0, typename Opnd1>
inline typename m_Intrinsic_Ty<Opnd0, Opnd1>::Ty m_FMin(const Opnd0 &Op0,
const Opnd1 &Op1) {
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=338111&r1=338110&r2=338111&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Fri Jul 27 02:04:35 2018
@@ -2098,8 +2098,8 @@ Instruction *InstCombiner::visitCallInst
}
// fma fabs(x), fabs(x), z -> fma x, x, z
- if (match(Src0, m_Intrinsic<Intrinsic::fabs>(m_Value(X))) &&
- match(Src1, m_Intrinsic<Intrinsic::fabs>(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 @@ Instruction *InstCombiner::visitCallInst
Value *SrcSrc;
Value *Src = II->getArgOperand(0);
if (match(Src, m_FNeg(m_Value(SrcSrc))) ||
- match(Src, m_Intrinsic<Intrinsic::fabs>(m_Value(SrcSrc)))) {
+ match(Src, m_FAbs(m_Value(SrcSrc)))) {
// cos(-x) -> cos(x)
// cos(fabs(x)) -> cos(x)
II->setArgOperand(0, SrcSrc);
More information about the llvm-commits
mailing list