-/// ShouldSplitFirstBlock - We need to either split MBB1 at MBB1I or MBB2 at
-/// MBB2I and then insert an unconditional branch in the other block. Determine
-/// which is the best to split
-static bool ShouldSplitFirstBlock(MachineBasicBlock *MBB1,
- MachineBasicBlock::iterator MBB1I,
- MachineBasicBlock *MBB2,
- MachineBasicBlock::iterator MBB2I,
- MachineBasicBlock *PredBB) {
- // If one block is the entry block, split the other one; we can't generate
- // a branch to the entry block, as its label is not emitted.
- MachineBasicBlock *Entry = MBB1->getParent()->begin();
- if (MBB1 == Entry)
- return false;
- if (MBB2 == Entry)
- return true;
-
- // If one block falls through into the common successor, choose that
- // one to split; it is one instruction less to do that.
- if (PredBB) {
- if (MBB1 == PredBB)
- return true;
- else if (MBB2 == PredBB)
- return false;
- }
- // TODO: if we had some notion of which block was hotter, we could split
- // the hot block, so it is the fall-through. Since we don't have profile info
- // make a decision based on which will hurt most to split.
- unsigned MBB1Time = EstimateRuntime(MBB1->begin(), MBB1I);
- unsigned MBB2Time = EstimateRuntime(MBB2->begin(), MBB2I);
-
- // If the MBB1 prefix takes "less time" to run than the MBB2 prefix, split the
- // MBB1 block so it falls through. This will penalize the MBB2 path, but will
- // have a lower overall impact on the program execution.
- return MBB1Time < MBB2Time;
-}
-