Skip to content

Commit 28799f3

Browse files
committed
[IVDescriptor] Explicitly check for isMinMaxRecurrenceKind in getReductionOpChain. NFC
There are other types of recurrences with an icmp/fcmp opcode, AnyOf and FindLastIV, so don't rely on the opcode to detect them. This makes adding support for AnyOf in llvm#131830 easier. Note that these currently fail the ExpectedUses/isCorrectOpcode checks anyway, so there shouldn't be any functional change.
1 parent f6ad65a commit 28799f3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,15 +1184,15 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
11841184
// more expensive than out-of-loop reductions, and need to be costed more
11851185
// carefully.
11861186
unsigned ExpectedUses = 1;
1187-
if (RedOp == Instruction::ICmp || RedOp == Instruction::FCmp)
1187+
if (isMinMaxRecurrenceKind(Kind))
11881188
ExpectedUses = 2;
11891189

11901190
auto getNextInstruction = [&](Instruction *Cur) -> Instruction * {
11911191
for (auto *User : Cur->users()) {
11921192
Instruction *UI = cast<Instruction>(User);
11931193
if (isa<PHINode>(UI))
11941194
continue;
1195-
if (RedOp == Instruction::ICmp || RedOp == Instruction::FCmp) {
1195+
if (isMinMaxRecurrenceKind(Kind)) {
11961196
// We are expecting a icmp/select pair, which we go to the next select
11971197
// instruction if we can. We already know that Cur has 2 uses.
11981198
if (isa<SelectInst>(UI))
@@ -1204,7 +1204,7 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
12041204
return nullptr;
12051205
};
12061206
auto isCorrectOpcode = [&](Instruction *Cur) {
1207-
if (RedOp == Instruction::ICmp || RedOp == Instruction::FCmp) {
1207+
if (isMinMaxRecurrenceKind(Kind)) {
12081208
Value *LHS, *RHS;
12091209
return SelectPatternResult::isMinOrMax(
12101210
matchSelectPattern(Cur, LHS, RHS).Flavor);

0 commit comments

Comments
 (0)