Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,32 @@ inline int_pred_ty<is_zero_int> m_ZeroInt() {
/// For vectors, this includes constants with undefined elements.
inline int_pred_ty<is_one> m_One() { return int_pred_ty<is_one>(); }

struct apint_match {
const APInt *&Res;

apint_match(const APInt *&Res) : Res(Res) {}

bool match(VPValue *VPV) const {
if (!VPV->isLiveIn())
return false;
Value *V = VPV->getLiveInIRValue();
if (!V)
return false;
const auto *CI = dyn_cast<ConstantInt>(V);
if (!CI && V->getType()->isVectorTy())
if (const auto *C = dyn_cast<Constant>(V))
CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue(/*AllowPoison=*/false));
if (!CI)
return false;
Res = &CI->getValue();
return true;
}
};

/// Match an APInt, capturing it if we match.
inline apint_match m_APInt(const APInt *&C) { return C; }

/// Matching combinators
template <typename LTy, typename RTy> struct match_combine_or {
LTy L;
Expand Down
9 changes: 5 additions & 4 deletions llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,11 +1592,12 @@ static bool tryToReplaceALMWithWideALM(VPlan &Plan, ElementCount VF,
m_ActiveLaneMask(m_VPValue(Index), m_VPValue(), m_VPValue()));
assert(Index && "Expected index from ActiveLaneMask instruction");

auto *II = dyn_cast<VPInstruction>(Index);
if (II && II->getOpcode() == VPInstruction::CanonicalIVIncrementForPart) {
auto Part = cast<ConstantInt>(II->getOperand(1)->getLiveInIRValue());
const APInt *Part;
if (match(Index,
m_VPInstruction<VPInstruction::CanonicalIVIncrementForPart>(
m_VPValue(), m_APInt(Part))))
Phis[Part->getZExtValue()] = Phi;
} else
else
// Anything other than a CanonicalIVIncrementForPart is part 0
Phis[0] = Phi;
}
Expand Down
Loading