[MBP] Don't move bottom block before header if it can't reduce taken branches
authorGuozhi Wei <carrot@google.com>
Fri, 25 Jan 2019 19:45:13 +0000 (19:45 +0000)
committerGuozhi Wei <carrot@google.com>
Fri, 25 Jan 2019 19:45:13 +0000 (19:45 +0000)
commit81f3fd4bf81247480d2fa172a65b04951e7a0d3e
tree0bb6b2d6785872d844ecf88b1a11a1001f54d6cb
parent165ea58798b2f51180a44ae734d8da8a06abf81a
[MBP] Don't move bottom block before header if it can't reduce taken branches

If bottom of block BB has only one successor OldTop, in most cases it is profitable to move it before OldTop, except the following case:

-->OldTop<-
|    .    |
|    .    |
|    .    |
---Pred   |
     |    |
    BB-----

Move BB before OldTop can't reduce the number of taken branches, this patch detects this case and prevent the moving.

Differential Revision: https://reviews.llvm.org/D57067

llvm-svn: 352236
llvm/lib/CodeGen/MachineBlockPlacement.cpp
llvm/test/CodeGen/AMDGPU/si-annotate-cf.ll
llvm/test/CodeGen/PowerPC/licm-remat.ll
llvm/test/CodeGen/X86/2009-02-26-MachineLICMBug.ll
llvm/test/CodeGen/X86/avx-cmp.ll
llvm/test/CodeGen/X86/avx512-i1test.ll
llvm/test/CodeGen/X86/code_placement_no_header_change.ll [new file with mode: 0644]
llvm/test/DebugInfo/X86/PR37234.ll