diff --git a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h index 18ab7ddb425ab..eb9ecdfe5e7bb 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h +++ b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h @@ -361,6 +361,12 @@ m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) { return AllRecipe_commutative_match(Op0, Op1); } +template +inline AllRecipe_commutative_match +m_c_Add(const Op0_t &Op0, const Op1_t &Op1) { + return m_c_Binary(Op0, Op1); +} + template inline AllRecipe_match m_Sub(const Op0_t &Op0, const Op1_t &Op1) { diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index b25fc0af1fb51..3a097645cd661 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -741,8 +741,7 @@ static VPWidenInductionRecipe *getOptimizableIVOf(VPValue *VPV) { VPValue *IVStep = WideIV->getStepValue(); switch (ID.getInductionOpcode()) { case Instruction::Add: - return match(VPV, m_c_Binary(m_Specific(WideIV), - m_Specific(IVStep))); + return match(VPV, m_c_Add(m_Specific(WideIV), m_Specific(IVStep))); case Instruction::FAdd: return match(VPV, m_c_Binary(m_Specific(WideIV), m_Specific(IVStep))); @@ -2231,9 +2230,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) { assert(all_of(Plan.getVFxUF().users(), [&Plan](VPUser *U) { - return match(U, m_c_Binary( - m_Specific(Plan.getCanonicalIV()), - m_Specific(&Plan.getVFxUF()))) || + return match(U, m_c_Add(m_Specific(Plan.getCanonicalIV()), + m_Specific(&Plan.getVFxUF()))) || isa(U); }) && "Only users of VFxUF should be VPWidenPointerInductionRecipe and the " @@ -2472,9 +2470,8 @@ void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) { // Replace CanonicalIVInc with EVL-PHI increment. auto *CanonicalIV = cast(&*HeaderVPBB->begin()); VPValue *Backedge = CanonicalIV->getIncomingValue(1); - assert(match(Backedge, - m_c_Binary(m_Specific(CanonicalIV), - m_Specific(&Plan.getVFxUF()))) && + assert(match(Backedge, m_c_Add(m_Specific(CanonicalIV), + m_Specific(&Plan.getVFxUF()))) && "Unexpected canonical iv"); Backedge->replaceAllUsesWith(EVLIncrement);