[llvm] [IndVars] Improve code; use SCEVPatternMatch (NFC) (PR #139533)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu May 22 09:02:53 PDT 2025
================
@@ -806,12 +807,9 @@ static bool isLoopCounter(PHINode* Phi, Loop *L,
if (!SE->isSCEVable(Phi->getType()))
return false;
- const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(Phi));
- if (!AR || AR->getLoop() != L || !AR->isAffine())
- return false;
-
- const SCEV *Step = dyn_cast<SCEVConstant>(AR->getStepRecurrence(*SE));
- if (!Step || !Step->isOne())
+ const SCEV *S = SE->getSCEV(Phi);
+ if (!match(S, m_scev_AffineAddRec(m_SCEV(), m_scev_One())) ||
+ cast<SCEVAddRecExpr>(S)->getLoop() != L)
----------------
nikic wrote:
Might make sense to have a m_scev_AffineAddRec variant that takes the Loop as an argument?
https://github.com/llvm/llvm-project/pull/139533
More information about the llvm-commits
mailing list