mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 21:29:41 +00:00
Fix Regression/Transforms/LoopStrengthReduce/phi_node_update_multiple_preds.ll
by being more careful about updating PHI nodes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22739 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3b7fd6647d
commit
c41e34520a
@ -423,21 +423,28 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PHI nodes are more complex. We have to insert one copy of the NewBase+Imm
|
// PHI nodes are more complex. We have to insert one copy of the NewBase+Imm
|
||||||
// expression into each operand block that uses it.
|
// expression into each operand block that uses it. Note that PHI nodes can
|
||||||
|
// have multiple entries for the same predecessor. We use a map to make sure
|
||||||
|
// that a PHI node only has a single Value* for each predecessor (which also
|
||||||
|
// prevents us from inserting duplicate code in some blocks).
|
||||||
|
std::map<BasicBlock*, Value*> InsertedCode;
|
||||||
PHINode *PN = cast<PHINode>(Inst);
|
PHINode *PN = cast<PHINode>(Inst);
|
||||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
|
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
|
||||||
if (PN->getIncomingValue(i) == OperandValToReplace) {
|
if (PN->getIncomingValue(i) == OperandValToReplace) {
|
||||||
// FIXME: this should split any critical edges.
|
// FIXME: this should split any critical edges.
|
||||||
|
|
||||||
// Insert the code into the end of the predecessor block.
|
Value *&Code = InsertedCode[PN->getIncomingBlock(i)];
|
||||||
BasicBlock::iterator InsertPt = PN->getIncomingBlock(i)->getTerminator();
|
if (!Code) {
|
||||||
|
// Insert the code into the end of the predecessor block.
|
||||||
|
BasicBlock::iterator InsertPt =PN->getIncomingBlock(i)->getTerminator();
|
||||||
|
|
||||||
SCEVHandle NewValSCEV = SCEVAddExpr::get(NewBase, Imm);
|
SCEVHandle NewValSCEV = SCEVAddExpr::get(NewBase, Imm);
|
||||||
Value *NewVal = Rewriter.expandCodeFor(NewValSCEV, InsertPt,
|
Code = Rewriter.expandCodeFor(NewValSCEV, InsertPt,
|
||||||
OperandValToReplace->getType());
|
OperandValToReplace->getType());
|
||||||
|
}
|
||||||
|
|
||||||
// Replace the use of the operand Value with the new Phi we just created.
|
// Replace the use of the operand Value with the new Phi we just created.
|
||||||
PN->setIncomingValue(i, NewVal);
|
PN->setIncomingValue(i, Code);
|
||||||
Rewriter.clear();
|
Rewriter.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user