Skip to content

Commit ea2a0ea

Browse files
lukel97github-actions[bot]
authored andcommitted
Automerge: [VPlan] Add m_c_Add to VPlanPatternMatch. NFC (#154730)
Same thing as #154705, and useful for simplifying the matching in #152167
2 parents a796cb1 + 5ef28e0 commit ea2a0ea

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
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_commutative_match<Instruction::Add, Op0_t, Op1_t>
366+
m_c_Add(const Op0_t &Op0, const Op1_t &Op1) {
367+
return m_c_Binary<Instruction::Add, Op0_t, Op1_t>(Op0, Op1);
368+
}
369+
364370
template <typename Op0_t, typename Op1_t>
365371
inline AllRecipe_match<Instruction::Sub, Op0_t, Op1_t> m_Sub(const Op0_t &Op0,
366372
const Op1_t &Op1) {

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,7 @@ static VPWidenInductionRecipe *getOptimizableIVOf(VPValue *VPV) {
741741
VPValue *IVStep = WideIV->getStepValue();
742742
switch (ID.getInductionOpcode()) {
743743
case Instruction::Add:
744-
return match(VPV, m_c_Binary<Instruction::Add>(m_Specific(WideIV),
745-
m_Specific(IVStep)));
744+
return match(VPV, m_c_Add(m_Specific(WideIV), m_Specific(IVStep)));
746745
case Instruction::FAdd:
747746
return match(VPV, m_c_Binary<Instruction::FAdd>(m_Specific(WideIV),
748747
m_Specific(IVStep)));
@@ -2231,9 +2230,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
22312230

22322231
assert(all_of(Plan.getVFxUF().users(),
22332232
[&Plan](VPUser *U) {
2234-
return match(U, m_c_Binary<Instruction::Add>(
2235-
m_Specific(Plan.getCanonicalIV()),
2236-
m_Specific(&Plan.getVFxUF()))) ||
2233+
return match(U, m_c_Add(m_Specific(Plan.getCanonicalIV()),
2234+
m_Specific(&Plan.getVFxUF()))) ||
22372235
isa<VPWidenPointerInductionRecipe>(U);
22382236
}) &&
22392237
"Only users of VFxUF should be VPWidenPointerInductionRecipe and the "
@@ -2472,9 +2470,8 @@ void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) {
24722470
// Replace CanonicalIVInc with EVL-PHI increment.
24732471
auto *CanonicalIV = cast<VPPhi>(&*HeaderVPBB->begin());
24742472
VPValue *Backedge = CanonicalIV->getIncomingValue(1);
2475-
assert(match(Backedge,
2476-
m_c_Binary<Instruction::Add>(m_Specific(CanonicalIV),
2477-
m_Specific(&Plan.getVFxUF()))) &&
2473+
assert(match(Backedge, m_c_Add(m_Specific(CanonicalIV),
2474+
m_Specific(&Plan.getVFxUF()))) &&
24782475
"Unexpected canonical iv");
24792476
Backedge->replaceAllUsesWith(EVLIncrement);
24802477

0 commit comments

Comments
 (0)