forked from OSchip/llvm-project
Change SplitBlock to increment a BasicBlock::iterator, not an Instruction*. Apparently they do different things :)
This fixes a testcase that nate reduced from spass. Also included are a couple minor code changes that don't affect the generated code at all. llvm-svn: 26235
This commit is contained in:
parent
01afec2adb
commit
fa335f6083
|
@ -397,9 +397,10 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L){
|
||||||
/// the loop info is updated.
|
/// the loop info is updated.
|
||||||
///
|
///
|
||||||
BasicBlock *LoopUnswitch::SplitBlock(BasicBlock *Old, Instruction *SplitPt) {
|
BasicBlock *LoopUnswitch::SplitBlock(BasicBlock *Old, Instruction *SplitPt) {
|
||||||
while (isa<PHINode>(SplitPt))
|
BasicBlock::iterator SplitIt = SplitPt;
|
||||||
++SplitPt;
|
while (isa<PHINode>(SplitIt))
|
||||||
BasicBlock *New = Old->splitBasicBlock(SplitPt, Old->getName()+".split");
|
++SplitIt;
|
||||||
|
BasicBlock *New = Old->splitBasicBlock(SplitIt, Old->getName()+".split");
|
||||||
|
|
||||||
// The new block lives in whichever loop the old one did.
|
// The new block lives in whichever loop the old one did.
|
||||||
if (Loop *L = LI->getLoopFor(Old))
|
if (Loop *L = LI->getLoopFor(Old))
|
||||||
|
@ -703,8 +704,10 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,
|
||||||
// Haha, this loop could be unswitched. Get it? The unswitch pass could
|
// Haha, this loop could be unswitched. Get it? The unswitch pass could
|
||||||
// unswitch itself. Amazing.
|
// unswitch itself. Amazing.
|
||||||
for (unsigned i = 0, e = Users.size(); i != e; ++i)
|
for (unsigned i = 0, e = Users.size(); i != e; ++i)
|
||||||
if (Instruction *U = cast<Instruction>(Users[i]))
|
if (Instruction *U = cast<Instruction>(Users[i])) {
|
||||||
if (L->contains(U->getParent()))
|
if (!L->contains(U->getParent()))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (IsEqual) {
|
if (IsEqual) {
|
||||||
U->replaceUsesOfWith(LIC, Val);
|
U->replaceUsesOfWith(LIC, Val);
|
||||||
} else if (NotVal) {
|
} else if (NotVal) {
|
||||||
|
@ -726,4 +729,5 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,
|
||||||
|
|
||||||
// TODO: We could simplify stuff like X == C.
|
// TODO: We could simplify stuff like X == C.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue