summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2017-05-17 04:09:14 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2017-05-17 04:09:14 +0000
commit4c7f293d24c7126ef4dfa1c3fe52d76c44105ff7 (patch)
tree15be1234fda879f4766350287ff38ec5dbc4fb24
parentb67d344850908bb2a98181c4cd4dc0a8fccf5be5 (diff)
downloadbcm5719-llvm-4c7f293d24c7126ef4dfa1c3fe52d76c44105ff7.tar.gz
bcm5719-llvm-4c7f293d24c7126ef4dfa1c3fe52d76c44105ff7.zip
[SCEV] Always sort AddRecExprs from different loops by dominance
Sorting of AddRecExprs by loop nesting does not make sense since we only invoke the CompareSCEVComplexity for AddRecExprs that are used by one SCEV. This guarantees that there is always a dominance relationship between them. This patch removes the sorting by nesting which is a dead code in current usage of this function. Reviewed By: sanjoy Differential Revision: https://reviews.llvm.org/D33228 llvm-svn: 303235
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 69fb1ae7dfe..a746ddfd7a6 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -629,19 +629,19 @@ static int CompareSCEVComplexity(
const SCEVAddRecExpr *LA = cast<SCEVAddRecExpr>(LHS);
const SCEVAddRecExpr *RA = cast<SCEVAddRecExpr>(RHS);
- // If there is a dominance relationship between the loops, sort by the
- // dominance. Otherwise, sort by depth. We require such order in getAddExpr.
+ // There is always a dominance between two recs that are used by one SCEV,
+ // so we can safely sort recs by loop header dominance. We require such
+ // order in getAddExpr.
const Loop *LLoop = LA->getLoop(), *RLoop = RA->getLoop();
if (LLoop != RLoop) {
const BasicBlock *LHead = LLoop->getHeader(), *RHead = RLoop->getHeader();
assert(LHead != RHead && "Two loops share the same header?");
if (DT.dominates(LHead, RHead))
return 1;
- else if (DT.dominates(RHead, LHead))
- return -1;
- unsigned LDepth = LLoop->getLoopDepth(), RDepth = RLoop->getLoopDepth();
- if (LDepth != RDepth)
- return (int)LDepth - (int)RDepth;
+ else
+ assert(DT.dominates(RHead, LHead) &&
+ "No dominance between recurrences used by one SCEV?");
+ return -1;
}
// Addrec complexity grows with operand count.
OpenPOWER on IntegriCloud