Skip to content

Commit 955c475

Browse files
authored
[VPlan] Add m_Sub to VPlanPatternMatch. NFC (#154705)
To mirror PatternMatch.h, and we'll also be able to use it in #152167
1 parent 7439d22 commit 955c475

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,12 @@ m_c_Binary(const Op0_t &Op0, const Op1_t &Op1) {
361361
return AllRecipe_commutative_match<Opcode, Op0_t, Op1_t>(Op0, Op1);
362362
}
363363

364+
template <typename Op0_t, typename Op1_t>
365+
inline AllRecipe_match<Instruction::Sub, Op0_t, Op1_t> m_Sub(const Op0_t &Op0,
366+
const Op1_t &Op1) {
367+
return m_Binary<Instruction::Sub, Op0_t, Op1_t>(Op0, Op1);
368+
}
369+
364370
template <typename Op0_t, typename Op1_t>
365371
inline AllRecipe_match<Instruction::Mul, Op0_t, Op1_t> m_Mul(const Op0_t &Op0,
366372
const Op1_t &Op1) {

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ VPPartialReductionRecipe::computeCost(ElementCount VF,
326326
// Pick out opcode, type/ext information and use sub side effects from a widen
327327
// recipe.
328328
auto HandleWiden = [&](VPWidenRecipe *Widen) {
329-
if (match(Widen,
330-
m_Binary<Instruction::Sub>(m_SpecificInt(0), m_VPValue(Op)))) {
329+
if (match(Widen, m_Sub(m_SpecificInt(0), m_VPValue(Op)))) {
331330
Widen = dyn_cast<VPWidenRecipe>(Op->getDefiningRecipe());
332331
}
333332
Opcode = Widen->getOpcode();

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,7 @@ static VPWidenInductionRecipe *getOptimizableIVOf(VPValue *VPV) {
753753
// IVStep will be the negated step of the subtraction. Check if Step == -1
754754
// * IVStep.
755755
VPValue *Step;
756-
if (!match(VPV,
757-
m_Binary<Instruction::Sub>(m_VPValue(), m_VPValue(Step))) ||
756+
if (!match(VPV, m_Sub(m_VPValue(), m_VPValue(Step))) ||
758757
!Step->isLiveIn() || !IVStep->isLiveIn())
759758
return false;
760759
auto *StepCI = dyn_cast<ConstantInt>(Step->getLiveInIRValue());

0 commit comments

Comments
 (0)