Skip to content

Commit c458e9e

Browse files
committed
[IVDescriptors][NFC] Refactor getReductionOpChain to remove the dependency of non-arithmetic reductions on getOpcode.
1 parent c96f019 commit c458e9e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

llvm/include/llvm/Analysis/IVDescriptors.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ class RecurrenceDescriptor {
232232
/// Returns true if the recurrence kind is a floating point kind.
233233
static bool isFloatingPointRecurrenceKind(RecurKind Kind);
234234

235+
/// Returns true if the recurrence kind is arithmetic.
236+
static bool isArithmeticRecurrenceKind(RecurKind Kind);
237+
235238
/// Returns true if the recurrence kind is an integer min/max kind.
236239
static bool isIntMinMaxRecurrenceKind(RecurKind Kind) {
237240
return Kind == RecurKind::UMin || Kind == RecurKind::UMax ||

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ bool RecurrenceDescriptor::isFloatingPointRecurrenceKind(RecurKind Kind) {
6262
return (Kind != RecurKind::None) && !isIntegerRecurrenceKind(Kind);
6363
}
6464

65+
bool RecurrenceDescriptor::isArithmeticRecurrenceKind(RecurKind Kind) {
66+
return (Kind != RecurKind::None) && !isMinMaxRecurrenceKind(Kind) &&
67+
!isAnyOfRecurrenceKind(Kind);
68+
}
69+
6570
/// Determines if Phi may have been type-promoted. If Phi has a single user
6671
/// that ANDs the Phi with a type mask, return the user. RT is updated to
6772
/// account for the narrower bit width represented by the mask, and the AND
@@ -1189,7 +1194,6 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
11891194
SmallVector<Instruction *, 4>
11901195
RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
11911196
SmallVector<Instruction *, 4> ReductionOperations;
1192-
unsigned RedOp = getOpcode();
11931197
const bool IsMinMax = isMinMaxRecurrenceKind(Kind);
11941198

11951199
// Search down from the Phi to the LoopExitInstr, looking for instructions
@@ -1237,7 +1241,7 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
12371241
if (isFMulAddIntrinsic(Cur))
12381242
return true;
12391243

1240-
return Cur->getOpcode() == RedOp;
1244+
return Cur->getOpcode() == getOpcode();
12411245
};
12421246

12431247
// Attempt to look through Phis which are part of the reduction chain

0 commit comments

Comments
 (0)