Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 27 additions & 0 deletions llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,33 @@ 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 bind_const_int {
uint64_t &Res;

bind_const_int(uint64_t &Res) : Res(Res) {}

bool match(VPValue *VPV) const {
if (!VPV->isLiveIn())
return false;
Value *V = VPV->getLiveInIRValue();
if (!V)
return false;
assert(!V->getType()->isVectorTy() && "Unexpected vector live-in");
const auto *CI = dyn_cast<ConstantInt>(V);
if (!CI)
return false;
if (auto C = CI->getValue().tryZExtValue()) {
Res = *C;
return true;
}
return false;
}
};

/// Match a plain integer constant no wider than 64-bits, capturing it if we
/// match.
inline bind_const_int m_ConstantInt(uint64_t &C) { return C; }

/// Matching combinators
template <typename LTy, typename RTy> struct match_combine_or {
LTy L;
Expand Down
11 changes: 6 additions & 5 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());
Phis[Part->getZExtValue()] = Phi;
} else
uint64_t Part;
if (match(Index,
m_VPInstruction<VPInstruction::CanonicalIVIncrementForPart>(
m_VPValue(), m_ConstantInt(Part))))
Phis[Part] = Phi;
else
// Anything other than a CanonicalIVIncrementForPart is part 0
Phis[0] = Phi;
}
Expand Down