diff options
Diffstat (limited to 'llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h')
-rw-r--r-- | llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h b/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h index 871028d..9354eef 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h @@ -95,6 +95,10 @@ inline bind_ty<const SCEVAddExpr> m_scev_Add(const SCEVAddExpr *&V) { return V; } +inline bind_ty<const SCEVMulExpr> m_scev_Mul(const SCEVMulExpr *&V) { + return V; +} + /// Match a specified const SCEV *. struct specificscev_ty { const SCEV *Expr; @@ -252,6 +256,18 @@ m_scev_UDiv(const Op0_t &Op0, const Op1_t &Op1) { return m_scev_Binary<SCEVUDivExpr>(Op0, Op1); } +template <typename Op0_t, typename Op1_t> +inline SCEVBinaryExpr_match<SCEVSMaxExpr, Op0_t, Op1_t> +m_scev_SMax(const Op0_t &Op0, const Op1_t &Op1) { + return m_scev_Binary<SCEVSMaxExpr>(Op0, Op1); +} + +template <typename Op0_t, typename Op1_t> +inline SCEVBinaryExpr_match<SCEVMinMaxExpr, Op0_t, Op1_t> +m_scev_MinMax(const Op0_t &Op0, const Op1_t &Op1) { + return m_scev_Binary<SCEVMinMaxExpr>(Op0, Op1); +} + /// Match unsigned remainder pattern. /// Matches patterns generated by getURemExpr. template <typename Op0_t, typename Op1_t> struct SCEVURem_match { @@ -284,14 +300,10 @@ template <typename Op0_t, typename Op1_t> struct SCEVURem_match { << SE.getTypeSizeInBits(TruncTy)); return Op0.match(LHS) && Op1.match(RHS); } - const auto *Add = dyn_cast<SCEVAddExpr>(Expr); - if (Add == nullptr || Add->getNumOperands() != 2) - return false; - - const SCEV *A = Add->getOperand(1); - const auto *Mul = dyn_cast<SCEVMulExpr>(Add->getOperand(0)); - if (Mul == nullptr) + const SCEV *A; + const SCEVMulExpr *Mul; + if (!SCEVPatternMatch::match(Expr, m_scev_Add(m_scev_Mul(Mul), m_SCEV(A)))) return false; const auto MatchURemWithDivisor = [&](const SCEV *B) { |