forked from OSchip/llvm-project
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
This commit is contained in:
parent
b56be389c8
commit
33e7bc0029
|
@ -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 is scConstant, it may be worse to reuse an existing Value.
|
||||||
if (S->getSCEVType() != scConstant && Set) {
|
if (S->getSCEVType() != scConstant && Set) {
|
||||||
// Choose a Value from the set which dominates the insertPt.
|
// 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) {
|
for (auto const &Ent : *Set) {
|
||||||
if (Ent && isa<Instruction>(Ent) && S->getType() == Ent->getType() &&
|
Instruction *EntInst = nullptr;
|
||||||
cast<Instruction>(Ent)->getFunction() == InsertPt->getFunction() &&
|
if (Ent && isa<Instruction>(Ent) &&
|
||||||
SE.DT.dominates(cast<Instruction>(Ent), InsertPt)) {
|
(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;
|
V = Ent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue