[MBP] do not reorder and move up loop latch block
Do not reorder and move up a loop latch block before a loop header when optimising for size because this will generate an extra unconditional branch. Differential Revision: https://reviews.llvm.org/D22521 llvm-svn: 278840
This commit is contained in:
@@ -966,6 +966,16 @@ void MachineBlockPlacement::buildChain(
|
||||
MachineBasicBlock *
|
||||
MachineBlockPlacement::findBestLoopTop(MachineLoop &L,
|
||||
const BlockFilterSet &LoopBlockSet) {
|
||||
// Placing the latch block before the header may introduce an extra branch
|
||||
// that skips this block the first time the loop is executed, which we want
|
||||
// to avoid when optimising for size.
|
||||
// FIXME: in theory there is a case that does not introduce a new branch,
|
||||
// i.e. when the layout predecessor does not fallthrough to the loop header.
|
||||
// In practice this never happens though: there always seems to be a preheader
|
||||
// that can fallthrough and that is also placed before the header.
|
||||
if (F->getFunction()->optForSize())
|
||||
return L.getHeader();
|
||||
|
||||
// Check that the header hasn't been fused with a preheader block due to
|
||||
// crazy branches. If it has, we need to start with the header at the top to
|
||||
// prevent pulling the preheader into the loop body.
|
||||
|
||||
Reference in New Issue
Block a user