Dereference loopHeader after checking for null rather than before.

llvm-svn: 90990
This commit is contained in:
Dan Gohman 2009-12-09 22:55:01 +00:00
parent 2262909b20
commit 72c367fb52
1 changed files with 2 additions and 1 deletions

View File

@ -404,12 +404,13 @@ bool LoopUnswitch::IsTrivialUnswitchCondition(Value *Cond, Constant **Val,
bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){
initLoopData();
Function *F = loopHeader->getParent();
// If LoopSimplify was unable to form a preheader, don't do any unswitching.
if (!loopPreheader)
return false;
Function *F = loopHeader->getParent();
// If the condition is trivial, always unswitch. There is no code growth for
// this case.
if (!IsTrivialUnswitchCondition(LoopCond)) {