summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-04-10 13:35:57 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-04-10 13:35:57 +0000
commit68062617a6e4fd5e2fefa0ebb99a36e77dcb0cff (patch)
tree28c9da5020654ce5736f65a2774afd54b96fdc3c /llvm/lib/CodeGen/MachineBlockPlacement.cpp
parent4d1220de348c5aaeef3b4183986c405543dacd98 (diff)
downloadbcm5719-llvm-68062617a6e4fd5e2fefa0ebb99a36e77dcb0cff.tar.gz
bcm5719-llvm-68062617a6e4fd5e2fefa0ebb99a36e77dcb0cff.zip
Make a somewhat subtle change in the logic of block placement. Sometimes
the loop header has a non-loop predecessor which has been pre-fused into its chain due to unanalyzable branches. In this case, rotating the header into the body of the loop in order to place a loop exit at the bottom of the loop is a Very Bad Idea as it makes the loop non-contiguous. I'm working on a good test case for this, but it's a bit annoynig to craft. I should get one shortly, but I'm submitting this now so I can begin the (lengthy) performance analysis process. An initial run of LNT looks really, really good, but there is too much noise there for me to trust it much. llvm-svn: 154395
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 52fde7f44b9..22d7212007f 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -547,6 +547,18 @@ MachineBasicBlock *
MachineBlockPlacement::findBestLoopTop(MachineFunction &F,
MachineLoop &L,
const BlockFilterSet &LoopBlockSet) {
+ // We don't want to layout the loop linearly in all cases. If the loop header
+ // is just a normal basic block in the loop, we want to look for what block
+ // within the loop is the best one to layout at the top. However, if the loop
+ // header has be pre-merged into a chain due to predecessors not having
+ // analyzable branches, *and* the predecessor it is merged with is *not* part
+ // of the loop, rotating the header into the middle of the loop will create
+ // a non-contiguous range of blocks which is Very Bad. So start with the
+ // header and only rotate if safe.
+ BlockChain &HeaderChain = *BlockToChain[L.getHeader()];
+ if (!LoopBlockSet.count(*HeaderChain.begin()))
+ return L.getHeader();
+
BlockFrequency BestExitEdgeFreq;
MachineBasicBlock *ExitingBB = 0;
MachineBasicBlock *LoopingBB = 0;
OpenPOWER on IntegriCloud