Preds.emplace_back(PredBlock);
}
- const unsigned PredCount = Preds.size();
+ // If there aren't any predecessors into which we can fold,
+ // don't bother checking the cost.
+ if (Preds.empty())
+ return Changed;
+
// Only allow this transformation if computing the condition doesn't involve
// too many instructions and these involved instructions can be executed
// unconditionally. We denote all involved instructions except the condition
// number of the bonus instructions we'll need to create when cloning into
// each predecessor does not exceed a certain threshold.
unsigned NumBonusInsts = 0;
+ const unsigned PredCount = Preds.size();
for (Instruction &I : *BB) {
// Don't check the branch condition comparison itself.
if (&I == Cond)