From: Max Kazantsev Date: Wed, 29 Nov 2017 10:54:16 +0000 (+0000) Subject: [SCEV][NFC] Break from loop after we found first non-Phi in getAddRecExprPHILiterally X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd9c0f58f9ff81181730d7184a63895eb9128d55;p=llvm [SCEV][NFC] Break from loop after we found first non-Phi in getAddRecExprPHILiterally git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319306 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index ee0bc37e3dc..b2bdb5538e5 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -1143,7 +1143,11 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized, for (auto &I : *L->getHeader()) { auto *PN = dyn_cast(&I); - if (!PN || !SE.isSCEVable(PN->getType())) + // Found first non-phi, the rest of instructions are also not Phis. + if (!PN) + break; + + if (!SE.isSCEVable(PN->getType())) continue; const SCEVAddRecExpr *PhiSCEV = dyn_cast(SE.getSCEV(PN));