[llvm] 08f0aa4 - [IVDescriptors] Call getOpcode on demand in getReductionOpChain. nfc (#118777)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 30 02:01:18 PDT 2025
Author: Mel Chen
Date: 2025-04-30T17:01:14+08:00
New Revision: 08f0aa48006a34ad24d70a500cf8e0c619f421bc
URL: https://github.com/llvm/llvm-project/commit/08f0aa48006a34ad24d70a500cf8e0c619f421bc
DIFF: https://github.com/llvm/llvm-project/commit/08f0aa48006a34ad24d70a500cf8e0c619f421bc.diff
LOG: [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.
Added:
Modified:
llvm/lib/Analysis/IVDescriptors.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp
index 76552e7488eb5..a216b0347b9fa 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -1189,7 +1189,6 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
SmallVector<Instruction *, 4>
RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
SmallVector<Instruction *, 4> ReductionOperations;
- unsigned RedOp = getOpcode();
const bool IsMinMax = isMinMaxRecurrenceKind(Kind);
// Search down from the Phi to the LoopExitInstr, looking for instructions
@@ -1237,7 +1236,7 @@ RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
if (isFMulAddIntrinsic(Cur))
return true;
- return Cur->getOpcode() == RedOp;
+ return Cur->getOpcode() == getOpcode();
};
// Attempt to look through Phis which are part of the reduction chain
More information about the llvm-commits
mailing list