Skip to content

Commit e009de2

Browse files
committed
[LV] Use VPlan pattern matching in adjustRecipesForReductions (NFC)
Replace the assert checking if CurrentLinkI is a CmpInst with a pattern matching check in the if condition. This uses VPlan-level pattern matching instead of inspecting the underlying instruction type.
1 parent d831f8d commit e009de2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8727,11 +8727,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
87278727
VecOp = Sub;
87288728
} else {
87298729
if (RecurrenceDescriptor::isMinMaxRecurrenceKind(Kind)) {
8730-
if (isa<VPWidenRecipe>(CurrentLink)) {
8731-
assert(isa<CmpInst>(CurrentLinkI) &&
8732-
"need to have the compare of the select");
8730+
if (match(CurrentLink, m_Cmp(m_VPValue(), m_VPValue())))
87338731
continue;
8734-
}
87358732
assert(isa<VPWidenSelectRecipe>(CurrentLink) &&
87368733
"must be a select recipe");
87378734
IndexOfFirstOperand = 1;

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ template <typename Pattern> bool match(VPUser *U, const Pattern &P) {
2929
return R && match(R, P);
3030
}
3131

32+
template <typename Pattern> bool match(VPSingleDefRecipe *R, const Pattern &P) {
33+
return P.match(static_cast<const VPRecipeBase *>(R));
34+
}
35+
3236
template <typename Val, typename Pattern> struct VPMatchFunctor {
3337
const Pattern &P;
3438
VPMatchFunctor(const Pattern &P) : P(P) {}

0 commit comments

Comments
 (0)