Skip to content

Commit

Permalink
[SLP] make invalid operand explicit for extra arg in reduction matchi…
Browse files Browse the repository at this point in the history
…ng; NFC

This makes it clearer when we have encountered the extra arg.
Also, we may need to adjust the way the operand iteration
works when handling logical and/or.
  • Loading branch information
rotateright committed Jul 9, 2021
1 parent f8bef47 commit c2b7f09
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7288,6 +7288,8 @@ class HorizontalReduction {
/// The type of reduction operation.
RecurKind RdxKind;

const unsigned INVALID_OPERAND_INDEX = std::numeric_limits<unsigned>::max();

static bool isCmpSelMinMax(Instruction *I) {
return match(I, m_Select(m_Cmp(), m_Value(), m_Value())) &&
RecurrenceDescriptor::isMinMaxRecurrenceKind(getRdxKind(I));
Expand Down Expand Up @@ -7322,7 +7324,7 @@ class HorizontalReduction {
// in this case.
// Do not perform analysis of remaining operands of ParentStackElem.first
// instruction, this whole instruction is an extra argument.
ParentStackElem.second = getNumberOfOperands(ParentStackElem.first);
ParentStackElem.second = INVALID_OPERAND_INDEX;
} else {
// We ran into something like:
// ParentStackElem.first += ... + ExtraArg + ...
Expand Down Expand Up @@ -7636,7 +7638,7 @@ class HorizontalReduction {
bool IsReducedValue = TreeRdxKind != RdxKind;

// Postorder visit.
if (IsReducedValue || EdgeToVisit == getNumberOfOperands(TreeN)) {
if (IsReducedValue || EdgeToVisit >= getNumberOfOperands(TreeN)) {
if (IsReducedValue)
ReducedVals.push_back(TreeN);
else {
Expand Down

0 comments on commit c2b7f09

Please sign in to comment.