diff options
| author | Nick Lewycky <nicholas@mxc.ca> | 2008-12-11 17:40:14 +0000 |
|---|---|---|
| committer | Nick Lewycky <nicholas@mxc.ca> | 2008-12-11 17:40:14 +0000 |
| commit | 6a344e097c4bcac20a75c53d77d8a6fbc6db6914 (patch) | |
| tree | 73c2e88f1798611f6b513a693b29549687008427 /llvm/lib/Analysis/ScalarEvolution.cpp | |
| parent | 86242e1990e1eb653e50e3b5c296b42630023005 (diff) | |
| download | bcm5719-llvm-6a344e097c4bcac20a75c53d77d8a6fbc6db6914.tar.gz bcm5719-llvm-6a344e097c4bcac20a75c53d77d8a6fbc6db6914.zip | |
Sneaky, sneaky: move the -1 to the outside of the SMax. Reinstate the
optimization of SGE/SLE with unit stride, now that it works properly.
llvm-svn: 60881
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 2b714de3b3f..1dd5026d749 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -2924,8 +2924,12 @@ bool ScalarEvolutionsImpl::potentialInfiniteLoop(SCEV *Stride, SCEV *RHS, if (!R) return true; - if (isSigned) + if (isSigned) { + if (SC->getValue()->isOne()) + return R->getValue()->isMaxValue(true); + return true; // XXX: because we don't have an sdiv scev. + } // If negative, it wraps around every iteration, but we don't care about that. APInt S = SC->getValue()->getValue().abs(); @@ -2971,14 +2975,6 @@ HowManyLessThans(SCEV *LHS, SCEV *RHS, const Loop *L, // run (m-n)/s times. SCEVHandle End = RHS; - if (!executesAtLeastOnce(L, isSigned, trueWhenEqual, - SE.getMinusSCEV(Start, One), RHS)) { - // If not, we get the value of the LHS in the first iteration in which - // the above condition doesn't hold. This equals to max(m,n). - End = isSigned ? SE.getSMaxExpr(RHS, Start) - : SE.getUMaxExpr(RHS, Start); - } - // If the expression is less-than-or-equal to, we need to extend the // loop by one iteration. // @@ -2987,12 +2983,16 @@ HowManyLessThans(SCEV *LHS, SCEV *RHS, const Loop *L, // division would equal one, but the loop runs twice putting the // induction variable at 12. - if (!trueWhenEqual) - // (Stride - 1) is correct only because we know it's unsigned. - // What we really want is to decrease the magnitude of Stride by one. - Start = SE.getMinusSCEV(Start, SE.getMinusSCEV(Stride, One)); - else - Start = SE.getMinusSCEV(Start, Stride); + if (trueWhenEqual) + End = SE.getAddExpr(End, One); + + if (!executesAtLeastOnce(L, isSigned, trueWhenEqual, + SE.getMinusSCEV(Start, One), RHS)) { + // If not, we get the value of the LHS in the first iteration in which + // the above condition doesn't hold. This equals to max(m,n). + End = isSigned ? SE.getSMaxExpr(End, Start) + : SE.getUMaxExpr(End, Start); + } // Finally, we subtract these two values to get the number of times the // backedge is executed: max(m,n)-n. |

