summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Mi <wmi@google.com>2016-02-04 19:17:33 +0000
committerWei Mi <wmi@google.com>2016-02-04 19:17:33 +0000
commit33e7bc00293cad9c4e4fe85d74fbd085c487dfc0 (patch)
tree9ceaa20ddca79e82c406d3c438afc43073c7acf8
parentb56be389c8565ba588d5580a9f9f0622829cb12f (diff)
downloadbcm5719-llvm-33e7bc00293cad9c4e4fe85d74fbd085c487dfc0.tar.gz
bcm5719-llvm-33e7bc00293cad9c4e4fe85d74fbd085c487dfc0.zip
Fix a regression for r259736.
When SCEV expansion tries to reuse an existing value, it is needed to ensure that using the Value at the InsertPt will not break LCSSA. The fix adds a check that InsertPt is either inside the candidate Value's parent loop, or the candidate Value's parent loop is nullptr. llvm-svn: 259815
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionExpander.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
index f95e191e5ee..86cfe2d00ab 100644
--- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -1652,10 +1652,17 @@ Value *SCEVExpander::expand(const SCEV *S) {
// If S is scConstant, it may be worse to reuse an existing Value.
if (S->getSCEVType() != scConstant && Set) {
// Choose a Value from the set which dominates the insertPt.
+ // insertPt should be inside the Value's parent loop so as not to break
+ // the LCSSA form.
for (auto const &Ent : *Set) {
- if (Ent && isa<Instruction>(Ent) && S->getType() == Ent->getType() &&
- cast<Instruction>(Ent)->getFunction() == InsertPt->getFunction() &&
- SE.DT.dominates(cast<Instruction>(Ent), InsertPt)) {
+ Instruction *EntInst = nullptr;
+ if (Ent && isa<Instruction>(Ent) &&
+ (EntInst = cast<Instruction>(Ent)) &&
+ S->getType() == Ent->getType() &&
+ EntInst->getFunction() == InsertPt->getFunction() &&
+ SE.DT.dominates(EntInst, InsertPt) &&
+ (SE.LI.getLoopFor(EntInst->getParent()) == nullptr ||
+ SE.LI.getLoopFor(EntInst->getParent())->contains(InsertPt))) {
V = Ent;
break;
}
OpenPOWER on IntegriCloud