Code refactoring.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100262 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2010-04-03 02:23:43 +00:00
parent a6245247e9
commit 0272024210

View File

@@ -415,9 +415,15 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val) {
Function *F = loopHeader->getParent();
// If the condition is trivial, always unswitch. There is no code growth for
// this case.
if (!IsTrivialUnswitchCondition(LoopCond)) {
Constant *CondVal = 0;
BasicBlock *ExitBlock = 0;
if (IsTrivialUnswitchCondition(LoopCond, &CondVal, &ExitBlock)) {
// If the condition is trivial, always unswitch. There is no code growth
// for this case.
UnswitchTrivialCondition(currentLoop, LoopCond, CondVal, ExitBlock);
return true;
}
// Check to see if it would be profitable to unswitch current loop.
// Do not do non-trivial unswitch while optimizing for size.
@@ -445,16 +451,8 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val) {
<< currentLoop->getBlocks().size() << "\n");
return false;
}
}
Constant *CondVal;
BasicBlock *ExitBlock;
if (IsTrivialUnswitchCondition(LoopCond, &CondVal, &ExitBlock)) {
UnswitchTrivialCondition(currentLoop, LoopCond, CondVal, ExitBlock);
} else {
UnswitchNontrivialCondition(LoopCond, Val, currentLoop);
}
return true;
}