Skip to content

Commit edbaf1b

Browse files
committed
[IVDesc] Unify RecurKinds [I|F]FindLastIV (NFC)
1 parent 4fa2c62 commit edbaf1b

File tree

3 files changed

+33
-46
lines changed

3 files changed

+33
-46
lines changed

llvm/include/llvm/Analysis/IVDescriptors.h

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,32 @@ class StoreInst;
3131

3232
/// These are the kinds of recurrences that we support.
3333
enum class RecurKind {
34-
None, ///< Not a recurrence.
35-
Add, ///< Sum of integers.
36-
Mul, ///< Product of integers.
37-
Or, ///< Bitwise or logical OR of integers.
38-
And, ///< Bitwise or logical AND of integers.
39-
Xor, ///< Bitwise or logical XOR of integers.
40-
SMin, ///< Signed integer min implemented in terms of select(cmp()).
41-
SMax, ///< Signed integer max implemented in terms of select(cmp()).
42-
UMin, ///< Unsigned integer min implemented in terms of select(cmp()).
43-
UMax, ///< Unsigned integer max implemented in terms of select(cmp()).
44-
FAdd, ///< Sum of floats.
45-
FMul, ///< Product of floats.
46-
FMin, ///< FP min implemented in terms of select(cmp()).
47-
FMax, ///< FP max implemented in terms of select(cmp()).
48-
FMinimum, ///< FP min with llvm.minimum semantics
49-
FMaximum, ///< FP max with llvm.maximum semantics
34+
None, ///< Not a recurrence.
35+
Add, ///< Sum of integers.
36+
Mul, ///< Product of integers.
37+
Or, ///< Bitwise or logical OR of integers.
38+
And, ///< Bitwise or logical AND of integers.
39+
Xor, ///< Bitwise or logical XOR of integers.
40+
SMin, ///< Signed integer min implemented in terms of select(cmp()).
41+
SMax, ///< Signed integer max implemented in terms of select(cmp()).
42+
UMin, ///< Unsigned integer min implemented in terms of select(cmp()).
43+
UMax, ///< Unsigned integer max implemented in terms of select(cmp()).
44+
FAdd, ///< Sum of floats.
45+
FMul, ///< Product of floats.
46+
FMin, ///< FP min implemented in terms of select(cmp()).
47+
FMax, ///< FP max implemented in terms of select(cmp()).
48+
FMinimum, ///< FP min with llvm.minimum semantics
49+
FMaximum, ///< FP max with llvm.maximum semantics
5050
FMinimumNum, ///< FP min with llvm.minimumnum semantics
5151
FMaximumNum, ///< FP max with llvm.maximumnum semantics
52-
FMulAdd, ///< Sum of float products with llvm.fmuladd(a * b + sum).
53-
IAnyOf, ///< Any_of reduction with select(icmp(),x,y) where one of (x,y) is
54-
///< loop invariant, and both x and y are integer type.
55-
FAnyOf, ///< Any_of reduction with select(fcmp(),x,y) where one of (x,y) is
56-
///< 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.
52+
FMulAdd, ///< Sum of float products with llvm.fmuladd(a * b + sum).
53+
IAnyOf, ///< Any_of reduction with select(icmp(),x,y) where one of (x,y) is
54+
///< loop invariant, and both x and y are integer type.
55+
FAnyOf, ///< Any_of reduction with select(fcmp(),x,y) where one of (x,y) is
56+
///< loop invariant, and both x and y are integer type.
57+
FindLastIV, ///< FindLast reduction with select(cmp(),x,y) where one of
58+
///< (x,y) is increasing loop induction, and both x and y are
59+
///< integer type.
6360
// TODO: Any_of and FindLast reduction need not be restricted to integer type
6461
// only.
6562
};
@@ -259,7 +256,7 @@ class RecurrenceDescriptor {
259256
/// Returns true if the recurrence kind is of the form
260257
/// select(cmp(),x,y) where one of (x,y) is increasing loop induction.
261258
static bool isFindLastIVRecurrenceKind(RecurKind Kind) {
262-
return Kind == RecurKind::IFindLastIV || Kind == RecurKind::FFindLastIV;
259+
return Kind == RecurKind::FindLastIV;
263260
}
264261

265262
/// 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;
@@ -745,8 +744,7 @@ RecurrenceDescriptor::isFindLastIVPattern(Loop *TheLoop, PHINode *OrigPhi,
745744
if (!IsIncreasingLoopInduction(NonRdxPhi))
746745
return InstDesc(false, I);
747746

748-
return InstDesc(I, isa<ICmpInst>(I->getOperand(0)) ? RecurKind::IFindLastIV
749-
: RecurKind::FFindLastIV);
747+
return InstDesc(I, RecurKind::FindLastIV);
750748
}
751749

752750
RecurrenceDescriptor::InstDesc
@@ -993,13 +991,9 @@ bool RecurrenceDescriptor::isReductionPHI(PHINode *Phi, Loop *TheLoop,
993991
<< *Phi << "\n");
994992
return true;
995993
}
996-
if (AddReductionVar(Phi, RecurKind::IFindLastIV, TheLoop, FMF, RedDes, DB, AC,
994+
if (AddReductionVar(Phi, RecurKind::FindLastIV, TheLoop, FMF, RedDes, DB, AC,
997995
DT, SE)) {
998-
LLVM_DEBUG(dbgs() << "Found a "
999-
<< (RedDes.getRecurrenceKind() == RecurKind::FFindLastIV
1000-
? "F"
1001-
: "I")
1002-
<< "FindLastIV reduction PHI." << *Phi << "\n");
996+
LLVM_DEBUG(dbgs() << "Found a FindLastIV reduction PHI." << *Phi << "\n");
1003997
return true;
1004998
}
1005999
if (AddReductionVar(Phi, RecurKind::FMul, TheLoop, FMF, RedDes, DB, AC, DT,
@@ -1156,6 +1150,7 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
11561150
return Instruction::Mul;
11571151
case RecurKind::IAnyOf:
11581152
case RecurKind::FAnyOf:
1153+
case RecurKind::FindLastIV:
11591154
case RecurKind::Or:
11601155
return Instruction::Or;
11611156
case RecurKind::And:
@@ -1171,15 +1166,13 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
11711166
case RecurKind::SMin:
11721167
case RecurKind::UMax:
11731168
case RecurKind::UMin:
1174-
case RecurKind::IFindLastIV:
11751169
return Instruction::ICmp;
11761170
case RecurKind::FMax:
11771171
case RecurKind::FMin:
11781172
case RecurKind::FMaximum:
11791173
case RecurKind::FMinimum:
11801174
case RecurKind::FMaximumNum:
11811175
case RecurKind::FMinimumNum:
1182-
case RecurKind::FFindLastIV:
11831176
return Instruction::FCmp;
11841177
default:
11851178
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
@@ -23071,8 +23071,7 @@ class HorizontalReduction {
2307123071
case RecurKind::FMulAdd:
2307223072
case RecurKind::IAnyOf:
2307323073
case RecurKind::FAnyOf:
23074-
case RecurKind::IFindLastIV:
23075-
case RecurKind::FFindLastIV:
23074+
case RecurKind::FindLastIV:
2307623075
case RecurKind::FMaximumNum:
2307723076
case RecurKind::FMinimumNum:
2307823077
case RecurKind::None:
@@ -23207,8 +23206,7 @@ class HorizontalReduction {
2320723206
case RecurKind::FMulAdd:
2320823207
case RecurKind::IAnyOf:
2320923208
case RecurKind::FAnyOf:
23210-
case RecurKind::IFindLastIV:
23211-
case RecurKind::FFindLastIV:
23209+
case RecurKind::FindLastIV:
2321223210
case RecurKind::FMaximumNum:
2321323211
case RecurKind::FMinimumNum:
2321423212
case RecurKind::None:
@@ -23308,8 +23306,7 @@ class HorizontalReduction {
2330823306
case RecurKind::FMulAdd:
2330923307
case RecurKind::IAnyOf:
2331023308
case RecurKind::FAnyOf:
23311-
case RecurKind::IFindLastIV:
23312-
case RecurKind::FFindLastIV:
23309+
case RecurKind::FindLastIV:
2331323310
case RecurKind::FMaximumNum:
2331423311
case RecurKind::FMinimumNum:
2331523312
case RecurKind::None:

0 commit comments

Comments
 (0)