Skip to content

Commit c0578ed

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

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
@@ -230,6 +230,9 @@ class RecurrenceDescriptor {
230230
/// Returns true if the recurrence kind is a floating point kind.
231231
static bool isFloatingPointRecurrenceKind(RecurKind Kind);
232232

233+
/// Returns true if the recurrence kind is arithmetic.
234+
static bool isArithmeticRecurrenceKind(RecurKind Kind);
235+
233236
/// Returns true if the recurrence kind is an integer min/max kind.
234237
static bool isIntMinMaxRecurrenceKind(RecurKind Kind) {
235238
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
@@ -1166,7 +1171,6 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
11661171
SmallVector<Instruction *, 4>
11671172
RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
11681173
SmallVector<Instruction *, 4> ReductionOperations;
1169-
unsigned RedOp = getOpcode();
11701174
const bool IsMinMax = isMinMaxRecurrenceKind(Kind);
11711175

11721176
// Search down from the Phi to the LoopExitInstr, looking for instructions
@@ -1214,7 +1218,7 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
12141218
if (isFMulAddIntrinsic(Cur))
12151219
return true;
12161220

1217-
return Cur->getOpcode() == RedOp;
1221+
return Cur->getOpcode() == getOpcode();
12181222
};
12191223

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

0 commit comments

Comments
 (0)