mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-02 19:24:25 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73884 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -2958,18 +2958,18 @@ ScalarEvolution::ComputeBackedgeTakenCountFromExitCond(const Loop *L,
|
|||||||
if (L->contains(TBB)) {
|
if (L->contains(TBB)) {
|
||||||
// Both conditions must be true for the loop to continue executing.
|
// Both conditions must be true for the loop to continue executing.
|
||||||
// Choose the less conservative count.
|
// Choose the less conservative count.
|
||||||
// TODO: Take the minimum of the exact counts.
|
if (BTI0.Exact == CouldNotCompute)
|
||||||
if (BTI0.Exact == BTI1.Exact)
|
BECount = BTI1.Exact;
|
||||||
|
else if (BTI1.Exact == CouldNotCompute)
|
||||||
BECount = BTI0.Exact;
|
BECount = BTI0.Exact;
|
||||||
// TODO: Take the minimum of the maximum counts.
|
else
|
||||||
|
BECount = getUMinFromMismatchedTypes(BTI0.Exact, BTI1.Exact);
|
||||||
if (BTI0.Max == CouldNotCompute)
|
if (BTI0.Max == CouldNotCompute)
|
||||||
MaxBECount = BTI1.Max;
|
MaxBECount = BTI1.Max;
|
||||||
else if (BTI1.Max == CouldNotCompute)
|
else if (BTI1.Max == CouldNotCompute)
|
||||||
MaxBECount = BTI0.Max;
|
MaxBECount = BTI0.Max;
|
||||||
else if (const SCEVConstant *C0 = dyn_cast<SCEVConstant>(BTI0.Max))
|
else
|
||||||
if (const SCEVConstant *C1 = dyn_cast<SCEVConstant>(BTI1.Max))
|
MaxBECount = getUMinFromMismatchedTypes(BTI0.Max, BTI1.Max);
|
||||||
MaxBECount = getConstant(APIntOps::umin(C0->getValue()->getValue(),
|
|
||||||
C1->getValue()->getValue()));
|
|
||||||
} else {
|
} else {
|
||||||
// Both conditions must be true for the loop to exit.
|
// Both conditions must be true for the loop to exit.
|
||||||
assert(L->contains(FBB) && "Loop block has no successor in loop!");
|
assert(L->contains(FBB) && "Loop block has no successor in loop!");
|
||||||
@ -2992,18 +2992,18 @@ ScalarEvolution::ComputeBackedgeTakenCountFromExitCond(const Loop *L,
|
|||||||
if (L->contains(FBB)) {
|
if (L->contains(FBB)) {
|
||||||
// Both conditions must be false for the loop to continue executing.
|
// Both conditions must be false for the loop to continue executing.
|
||||||
// Choose the less conservative count.
|
// Choose the less conservative count.
|
||||||
// TODO: Take the minimum of the exact counts.
|
if (BTI0.Exact == CouldNotCompute)
|
||||||
if (BTI0.Exact == BTI1.Exact)
|
BECount = BTI1.Exact;
|
||||||
|
else if (BTI1.Exact == CouldNotCompute)
|
||||||
BECount = BTI0.Exact;
|
BECount = BTI0.Exact;
|
||||||
// TODO: Take the minimum of the maximum counts.
|
else
|
||||||
|
BECount = getUMinFromMismatchedTypes(BTI0.Exact, BTI1.Exact);
|
||||||
if (BTI0.Max == CouldNotCompute)
|
if (BTI0.Max == CouldNotCompute)
|
||||||
MaxBECount = BTI1.Max;
|
MaxBECount = BTI1.Max;
|
||||||
else if (BTI1.Max == CouldNotCompute)
|
else if (BTI1.Max == CouldNotCompute)
|
||||||
MaxBECount = BTI0.Max;
|
MaxBECount = BTI0.Max;
|
||||||
else if (const SCEVConstant *C0 = dyn_cast<SCEVConstant>(BTI0.Max))
|
else
|
||||||
if (const SCEVConstant *C1 = dyn_cast<SCEVConstant>(BTI1.Max))
|
MaxBECount = getUMinFromMismatchedTypes(BTI0.Max, BTI1.Max);
|
||||||
MaxBECount = getConstant(APIntOps::umin(C0->getValue()->getValue(),
|
|
||||||
C1->getValue()->getValue()));
|
|
||||||
} else {
|
} else {
|
||||||
// Both conditions must be false for the loop to exit.
|
// Both conditions must be false for the loop to exit.
|
||||||
assert(L->contains(TBB) && "Loop block has no successor in loop!");
|
assert(L->contains(TBB) && "Loop block has no successor in loop!");
|
||||||
|
Reference in New Issue
Block a user