diff options
author | Dan Gohman <gohman@apple.com> | 2010-06-19 14:17:24 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-06-19 14:17:24 +0000 |
commit | b92654d9c9cc34c75463e40d822fea4ac53950b3 (patch) | |
tree | e114cde4045bf2a467f25093550d8e0a61138ef5 /lib | |
parent | 485c43fc478d5e16c55e14cb2586b56cc1c4c91f (diff) | |
download | external_llvm-b92654d9c9cc34c75463e40d822fea4ac53950b3.zip external_llvm-b92654d9c9cc34c75463e40d822fea4ac53950b3.tar.gz external_llvm-b92654d9c9cc34c75463e40d822fea4ac53950b3.tar.bz2 |
Fix ScalarEvolution's "exhaustive" trip count evaluation code to avoid
assuming that loops are in canonical form, as ScalarEvolution doesn't
depend on LoopSimplify itself. Also, with indirectbr not all loops can
be simplified. This fixes PR7416.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 7e7fc75..251b57a 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -4238,8 +4238,11 @@ ScalarEvolution::ComputeBackedgeTakenCountExhaustively(const Loop *L, PHINode *PN = getConstantEvolvingPHI(Cond, L); if (PN == 0) return getCouldNotCompute(); - // Since the loop is canonicalized, the PHI node must have two entries. One - // entry must be a constant (coming in from outside of the loop), and the + // If the loop is canonicalized, the PHI will have exactly two entries. + // That's the only form we support here. + if (PN->getNumIncomingValues() != 2) return getCouldNotCompute(); + + // One entry must be a constant (coming in from outside of the loop), and the // second must be derived from the same PHI. bool SecondIsBackedge = L->contains(PN->getIncomingBlock(1)); Constant *StartCST = |