diff --git a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h index 9f036fbd569b6..18ab7ddb425ab 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_match m_Sub(const Op0_t &Op0, + const Op1_t &Op1) { + return m_Binary(Op0, Op1); +} + template inline AllRecipe_match m_Mul(const Op0_t &Op0, const Op1_t &Op1) { diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp index 7ca9b230f5aae..d7de7bb4f3a39 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp @@ -326,8 +326,7 @@ VPPartialReductionRecipe::computeCost(ElementCount VF, // Pick out opcode, type/ext information and use sub side effects from a widen // recipe. auto HandleWiden = [&](VPWidenRecipe *Widen) { - if (match(Widen, - m_Binary(m_SpecificInt(0), m_VPValue(Op)))) { + if (match(Widen, m_Sub(m_SpecificInt(0), m_VPValue(Op)))) { Widen = dyn_cast(Op->getDefiningRecipe()); } Opcode = Widen->getOpcode(); diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index cff43c2742a6b..e2a9fc50cb910 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -753,8 +753,7 @@ static VPWidenInductionRecipe *getOptimizableIVOf(VPValue *VPV) { // IVStep will be the negated step of the subtraction. Check if Step == -1 // * IVStep. VPValue *Step; - if (!match(VPV, - m_Binary(m_VPValue(), m_VPValue(Step))) || + if (!match(VPV, m_Sub(m_VPValue(), m_VPValue(Step))) || !Step->isLiveIn() || !IVStep->isLiveIn()) return false; auto *StepCI = dyn_cast(Step->getLiveInIRValue());