Skip to content

Commit

Permalink
SimpleLoopUnswitch - fix uninitialized variable and null dereference …
Browse files Browse the repository at this point in the history
…warnings. NFCI.

llvm-svn: 374986
  • Loading branch information
RKSimon committed Oct 16, 2019
1 parent b13d257 commit c598ef7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
Expand Up @@ -1909,7 +1909,7 @@ static void unswitchNontrivialInvariants(

// We can only unswitch switches, conditional branches with an invariant
// condition, or combining invariant conditions with an instruction.
assert((SI || BI->isConditional()) &&
assert((SI || (BI && BI->isConditional())) &&
"Can only unswitch switches and conditional branch!");
bool FullUnswitch = SI || BI->getCondition() == Invariants[0];
if (FullUnswitch)
Expand Down Expand Up @@ -2724,7 +2724,7 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,
return Cost * (SuccessorsCount - 1);
};
Instruction *BestUnswitchTI = nullptr;
int BestUnswitchCost;
int BestUnswitchCost = 0;
ArrayRef<Value *> BestUnswitchInvariants;
for (auto &TerminatorAndInvariants : UnswitchCandidates) {
Instruction &TI = *TerminatorAndInvariants.first;
Expand Down Expand Up @@ -2756,6 +2756,7 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,
BestUnswitchInvariants = Invariants;
}
}
assert(BestUnswitchTI && "Failed to find loop unswitch candidate");

if (BestUnswitchCost >= UnswitchThreshold) {
LLVM_DEBUG(dbgs() << "Cannot unswitch, lowest cost found: "
Expand Down

0 comments on commit c598ef7

Please sign in to comment.