summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-06-19 14:17:24 +0000
committerDan Gohman <gohman@apple.com>2010-06-19 14:17:24 +0000
commit866971ed3d30520c55f8948a4a608a5b0e260c52 (patch)
treecee7c3169b6758e2ee456ee1f870789d7e3a3a80 /llvm/lib/Analysis/ScalarEvolution.cpp
parentd27724613732d22ad36c5ba28f431f8c096d7c07 (diff)
downloadbcm5719-llvm-866971ed3d30520c55f8948a4a608a5b0e260c52.tar.gz
bcm5719-llvm-866971ed3d30520c55f8948a4a608a5b0e260c52.zip
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. llvm-svn: 106389
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 7e7fc756d10..251b57a0f98 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/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 =
OpenPOWER on IntegriCloud