Skip to content

Commit 784ca14

Browse files
committed
[VPlan/PM] Introduce m_ConstantInt
1 parent 3aa9735 commit 784ca14

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,26 @@ struct apint_match {
199199
}
200200
};
201201

202-
/// Match an APInt, capturing it if we match.
203-
inline apint_match m_APInt(const APInt *&C) { return C; }
202+
struct bind_const_intval_ty {
203+
uint64_t &VR;
204+
205+
bind_const_intval_ty(uint64_t &V) : VR(V) {}
206+
207+
template <typename ITy> bool match(ITy *V) const {
208+
const APInt *ConstInt;
209+
if (!apint_match(ConstInt).match(V))
210+
return false;
211+
if (auto C = ConstInt->tryZExtValue()) {
212+
VR = *C;
213+
return true;
214+
}
215+
return false;
216+
}
217+
};
218+
219+
/// Match a plain integer constant no wider than 64-bits, capturing it if we
220+
/// match.
221+
inline bind_const_intval_ty m_ConstantInt(uint64_t &C) { return C; }
204222

205223
/// Matching combinators
206224
template <typename LTy, typename RTy> struct match_combine_or {

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,11 +1592,11 @@ static bool tryToReplaceALMWithWideALM(VPlan &Plan, ElementCount VF,
15921592
m_ActiveLaneMask(m_VPValue(Index), m_VPValue(), m_VPValue()));
15931593
assert(Index && "Expected index from ActiveLaneMask instruction");
15941594

1595-
const APInt *Part;
1595+
uint64_t Part;
15961596
if (match(Index,
15971597
m_VPInstruction<VPInstruction::CanonicalIVIncrementForPart>(
1598-
m_VPValue(), m_APInt(Part))))
1599-
Phis[Part->getZExtValue()] = Phi;
1598+
m_VPValue(), m_ConstantInt(Part))))
1599+
Phis[Part] = Phi;
16001600
else
16011601
// Anything other than a CanonicalIVIncrementForPart is part 0
16021602
Phis[0] = Phi;

0 commit comments

Comments
 (0)