@@ -1167,6 +1167,7 @@ SmallVector<Instruction *, 4>
11671167RecurrenceDescriptor::getReductionOpChain (PHINode *Phi, Loop *L) const {
11681168 SmallVector<Instruction *, 4 > ReductionOperations;
11691169 unsigned RedOp = getOpcode ();
1170+ const bool IsMinMax = isMinMaxRecurrenceKind (Kind);
11701171
11711172 // Search down from the Phi to the LoopExitInstr, looking for instructions
11721173 // with a single user of the correct type for the reduction.
@@ -1184,15 +1185,15 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
11841185 // more expensive than out-of-loop reductions, and need to be costed more
11851186 // carefully.
11861187 unsigned ExpectedUses = 1 ;
1187- if (isMinMaxRecurrenceKind (Kind) )
1188+ if (IsMinMax )
11881189 ExpectedUses = 2 ;
11891190
11901191 auto getNextInstruction = [&](Instruction *Cur) -> Instruction * {
11911192 for (auto *User : Cur->users ()) {
11921193 Instruction *UI = cast<Instruction>(User);
11931194 if (isa<PHINode>(UI))
11941195 continue ;
1195- if (isMinMaxRecurrenceKind (Kind) ) {
1196+ if (IsMinMax ) {
11961197 // We are expecting a icmp/select pair, which we go to the next select
11971198 // instruction if we can. We already know that Cur has 2 uses.
11981199 if (isa<SelectInst>(UI))
@@ -1204,7 +1205,7 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
12041205 return nullptr ;
12051206 };
12061207 auto isCorrectOpcode = [&](Instruction *Cur) {
1207- if (isMinMaxRecurrenceKind (Kind) ) {
1208+ if (IsMinMax ) {
12081209 Value *LHS, *RHS;
12091210 return SelectPatternResult::isMinOrMax (
12101211 matchSelectPattern (Cur, LHS, RHS).Flavor );
0 commit comments