summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-22 15:09:28 +0000
committerDan Gohman <gohman@apple.com>2009-06-22 15:09:28 +0000
commited627385debcc1e5fe9a2502a99138f7dc2bdab7 (patch)
tree3239a2b556c365aba3c1ebdc99d1594ecd0de772
parent2bc22305d2eac43ac37519bdfd82b34b745dfc69 (diff)
downloadbcm5719-llvm-ed627385debcc1e5fe9a2502a99138f7dc2bdab7.tar.gz
bcm5719-llvm-ed627385debcc1e5fe9a2502a99138f7dc2bdab7.zip
Make use of getUMinFromMismatchedTypes when computing backedge-taken
counts for loops with multiple exits, replacing more conservative code which only handled constants. This is derived from a patch by Nick Lewycky. This also fixes llc aborts in ClamAV and others, as getUMinFromMismatchedTypes takes care of balancing the types before working with them. llvm-svn: 73884
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index d67761c60a3..7954d97a378 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -2958,18 +2958,18 @@ ScalarEvolution::ComputeBackedgeTakenCountFromExitCond(const Loop *L,
if (L->contains(TBB)) {
// Both conditions must be true for the loop to continue executing.
// Choose the less conservative count.
- // TODO: Take the minimum of the exact counts.
- if (BTI0.Exact == BTI1.Exact)
+ if (BTI0.Exact == CouldNotCompute)
+ BECount = BTI1.Exact;
+ else if (BTI1.Exact == CouldNotCompute)
BECount = BTI0.Exact;
- // TODO: Take the minimum of the maximum counts.
+ else
+ BECount = getUMinFromMismatchedTypes(BTI0.Exact, BTI1.Exact);
if (BTI0.Max == CouldNotCompute)
MaxBECount = BTI1.Max;
else if (BTI1.Max == CouldNotCompute)
MaxBECount = BTI0.Max;
- else if (const SCEVConstant *C0 = dyn_cast<SCEVConstant>(BTI0.Max))
- if (const SCEVConstant *C1 = dyn_cast<SCEVConstant>(BTI1.Max))
- MaxBECount = getConstant(APIntOps::umin(C0->getValue()->getValue(),
- C1->getValue()->getValue()));
+ else
+ MaxBECount = getUMinFromMismatchedTypes(BTI0.Max, BTI1.Max);
} else {
// Both conditions must be true for the loop to exit.
assert(L->contains(FBB) && "Loop block has no successor in loop!");
@@ -2992,18 +2992,18 @@ ScalarEvolution::ComputeBackedgeTakenCountFromExitCond(const Loop *L,
if (L->contains(FBB)) {
// Both conditions must be false for the loop to continue executing.
// Choose the less conservative count.
- // TODO: Take the minimum of the exact counts.
- if (BTI0.Exact == BTI1.Exact)
+ if (BTI0.Exact == CouldNotCompute)
+ BECount = BTI1.Exact;
+ else if (BTI1.Exact == CouldNotCompute)
BECount = BTI0.Exact;
- // TODO: Take the minimum of the maximum counts.
+ else
+ BECount = getUMinFromMismatchedTypes(BTI0.Exact, BTI1.Exact);
if (BTI0.Max == CouldNotCompute)
MaxBECount = BTI1.Max;
else if (BTI1.Max == CouldNotCompute)
MaxBECount = BTI0.Max;
- else if (const SCEVConstant *C0 = dyn_cast<SCEVConstant>(BTI0.Max))
- if (const SCEVConstant *C1 = dyn_cast<SCEVConstant>(BTI1.Max))
- MaxBECount = getConstant(APIntOps::umin(C0->getValue()->getValue(),
- C1->getValue()->getValue()));
+ else
+ MaxBECount = getUMinFromMismatchedTypes(BTI0.Max, BTI1.Max);
} else {
// Both conditions must be false for the loop to exit.
assert(L->contains(TBB) && "Loop block has no successor in loop!");
OpenPOWER on IntegriCloud