Skip to content

Commit b81170e

Browse files
authored
[IVDesc] Unify RecurKinds [I|F]FindLastIV (NFC) (#141082)
1 parent 5a1311d commit b81170e

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

llvm/include/llvm/Analysis/IVDescriptors.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class StoreInst;
3131

3232
/// These are the kinds of recurrences that we support.
3333
enum class RecurKind {
34+
// clang-format off
3435
None, ///< Not a recurrence.
3536
Add, ///< Sum of integers.
3637
Mul, ///< Product of integers.
@@ -54,12 +55,10 @@ enum class RecurKind {
5455
///< loop invariant, and both x and y are integer type.
5556
FAnyOf, ///< Any_of reduction with select(fcmp(),x,y) where one of (x,y) is
5657
///< loop invariant, and both x and y are integer type.
57-
IFindLastIV, ///< FindLast reduction with select(icmp(),x,y) where one of
58-
///< (x,y) is increasing loop induction, and both x and y are
59-
///< integer type.
60-
FFindLastIV ///< FindLast reduction with select(fcmp(),x,y) where one of (x,y)
61-
///< is increasing loop induction, and both x and y are integer
62-
///< type.
58+
FindLastIV, ///< FindLast reduction with select(cmp(),x,y) where one of
59+
///< (x,y) is increasing loop induction, and both x and y are
60+
///< integer type.
61+
// clang-format on
6362
// TODO: Any_of and FindLast reduction need not be restricted to integer type
6463
// only.
6564
};
@@ -259,7 +258,7 @@ class RecurrenceDescriptor {
259258
/// Returns true if the recurrence kind is of the form
260259
/// select(cmp(),x,y) where one of (x,y) is increasing loop induction.
261260
static bool isFindLastIVRecurrenceKind(RecurKind Kind) {
262-
return Kind == RecurKind::IFindLastIV || Kind == RecurKind::FFindLastIV;
261+
return Kind == RecurKind::FindLastIV;
263262
}
264263

265264
/// Returns the type of the recurrence. This type can be narrower than the

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ bool RecurrenceDescriptor::isIntegerRecurrenceKind(RecurKind Kind) {
5151
case RecurKind::UMin:
5252
case RecurKind::IAnyOf:
5353
case RecurKind::FAnyOf:
54-
case RecurKind::IFindLastIV:
55-
case RecurKind::FFindLastIV:
54+
case RecurKind::FindLastIV:
5655
return true;
5756
}
5857
return false;
@@ -743,8 +742,7 @@ RecurrenceDescriptor::isFindLastIVPattern(Loop *TheLoop, PHINode *OrigPhi,
743742
if (!IsIncreasingLoopInduction(NonRdxPhi))
744743
return InstDesc(false, I);
745744

746-
return InstDesc(I, isa<ICmpInst>(I->getOperand(0)) ? RecurKind::IFindLastIV
747-
: RecurKind::FFindLastIV);
745+
return InstDesc(I, RecurKind::FindLastIV);
748746
}
749747

750748
RecurrenceDescriptor::InstDesc
@@ -989,13 +987,9 @@ bool RecurrenceDescriptor::isReductionPHI(PHINode *Phi, Loop *TheLoop,
989987
<< *Phi << "\n");
990988
return true;
991989
}
992-
if (AddReductionVar(Phi, RecurKind::IFindLastIV, TheLoop, FMF, RedDes, DB, AC,
990+
if (AddReductionVar(Phi, RecurKind::FindLastIV, TheLoop, FMF, RedDes, DB, AC,
993991
DT, SE)) {
994-
LLVM_DEBUG(dbgs() << "Found a "
995-
<< (RedDes.getRecurrenceKind() == RecurKind::FFindLastIV
996-
? "F"
997-
: "I")
998-
<< "FindLastIV reduction PHI." << *Phi << "\n");
992+
LLVM_DEBUG(dbgs() << "Found a FindLastIV reduction PHI." << *Phi << "\n");
999993
return true;
1000994
}
1001995
if (AddReductionVar(Phi, RecurKind::FMul, TheLoop, FMF, RedDes, DB, AC, DT,
@@ -1152,6 +1146,7 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
11521146
return Instruction::Mul;
11531147
case RecurKind::IAnyOf:
11541148
case RecurKind::FAnyOf:
1149+
case RecurKind::FindLastIV:
11551150
case RecurKind::Or:
11561151
return Instruction::Or;
11571152
case RecurKind::And:
@@ -1167,15 +1162,13 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
11671162
case RecurKind::SMin:
11681163
case RecurKind::UMax:
11691164
case RecurKind::UMin:
1170-
case RecurKind::IFindLastIV:
11711165
return Instruction::ICmp;
11721166
case RecurKind::FMax:
11731167
case RecurKind::FMin:
11741168
case RecurKind::FMaximum:
11751169
case RecurKind::FMinimum:
11761170
case RecurKind::FMaximumNum:
11771171
case RecurKind::FMinimumNum:
1178-
case RecurKind::FFindLastIV:
11791172
return Instruction::FCmp;
11801173
default:
11811174
llvm_unreachable("Unknown recurrence operation");

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23091,8 +23091,7 @@ class HorizontalReduction {
2309123091
case RecurKind::FMulAdd:
2309223092
case RecurKind::IAnyOf:
2309323093
case RecurKind::FAnyOf:
23094-
case RecurKind::IFindLastIV:
23095-
case RecurKind::FFindLastIV:
23094+
case RecurKind::FindLastIV:
2309623095
case RecurKind::FMaximumNum:
2309723096
case RecurKind::FMinimumNum:
2309823097
case RecurKind::None:
@@ -23227,8 +23226,7 @@ class HorizontalReduction {
2322723226
case RecurKind::FMulAdd:
2322823227
case RecurKind::IAnyOf:
2322923228
case RecurKind::FAnyOf:
23230-
case RecurKind::IFindLastIV:
23231-
case RecurKind::FFindLastIV:
23229+
case RecurKind::FindLastIV:
2323223230
case RecurKind::FMaximumNum:
2323323231
case RecurKind::FMinimumNum:
2323423232
case RecurKind::None:
@@ -23328,8 +23326,7 @@ class HorizontalReduction {
2332823326
case RecurKind::FMulAdd:
2332923327
case RecurKind::IAnyOf:
2333023328
case RecurKind::FAnyOf:
23331-
case RecurKind::IFindLastIV:
23332-
case RecurKind::FFindLastIV:
23329+
case RecurKind::FindLastIV:
2333323330
case RecurKind::FMaximumNum:
2333423331
case RecurKind::FMinimumNum:
2333523332
case RecurKind::None:

0 commit comments

Comments
 (0)