Skip to content

Commit 08f0aa4

Browse files
authored
[IVDescriptors] Call getOpcode on demand in getReductionOpChain. nfc (#118777)
Non-arithmetic reductions do not require the binary opcodes. As a first step toward removing the dependency of non-arithmetic reductions on `getOpcode` function, this patch refactors the `getReductionOpChain` function. In the future, once all users of `getOpcode` function are refactored, an assertion can be added to `getOpcode` function to ensure that only arithmetic reductions rely on it.
1 parent 51c2602 commit 08f0aa4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

llvm/lib/Analysis/IVDescriptors.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,6 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
11891189
SmallVector<Instruction *, 4>
11901190
RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
11911191
SmallVector<Instruction *, 4> ReductionOperations;
1192-
unsigned RedOp = getOpcode();
11931192
const bool IsMinMax = isMinMaxRecurrenceKind(Kind);
11941193

11951194
// Search down from the Phi to the LoopExitInstr, looking for instructions
@@ -1237,7 +1236,7 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
12371236
if (isFMulAddIntrinsic(Cur))
12381237
return true;
12391238

1240-
return Cur->getOpcode() == RedOp;
1239+
return Cur->getOpcode() == getOpcode();
12411240
};
12421241

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

0 commit comments

Comments
 (0)