[MBP] Avoid tail duplication if it can't bring benefit
authorGuozhi Wei <carrot@google.com>
Thu, 5 Dec 2019 00:01:20 +0000 (16:01 -0800)
committerGuozhi Wei <carrot@google.com>
Fri, 6 Dec 2019 17:53:53 +0000 (09:53 -0800)
commit72942459d070cbfe6f3524e89c3ac37440be7890
tree6a45cb456c8fff75ba7c89eb4156254ef6d485d8
parent164e0fc5c7f782b174db5c87b37725ea0e174853
[MBP] Avoid tail duplication if it can't bring benefit

Current tail duplication integrated in bb layout is designed to increase the fallthrough from a BB's predecessor to its successor, but we have observed cases that duplication doesn't increase fallthrough, or it brings too much size overhead.

To overcome these two issues in function canTailDuplicateUnplacedPreds I add two checks:

  make sure there is at least one duplication in current work set.
  the number of duplication should not exceed the number of successors.

The modification in hasBetterLayoutPredecessor fixes a bug that potential predecessor must be at the bottom of a chain.

Differential Revision: https://reviews.llvm.org/D64376
25 files changed:
llvm/lib/CodeGen/MachineBlockPlacement.cpp
llvm/test/CodeGen/AArch64/callbr-asm-obj-file.ll
llvm/test/CodeGen/AArch64/swifterror.ll
llvm/test/CodeGen/AArch64/tbz-tbnz.ll
llvm/test/CodeGen/AMDGPU/loop_header_nopred.mir
llvm/test/CodeGen/AMDGPU/uniform-cfg.ll
llvm/test/CodeGen/PowerPC/block-placement.mir
llvm/test/CodeGen/PowerPC/branch-opt.ll
llvm/test/CodeGen/PowerPC/expand-contiguous-isel.ll
llvm/test/CodeGen/PowerPC/no-duplicate.ll [new file with mode: 0644]
llvm/test/CodeGen/RISCV/atomic-rmw.ll
llvm/test/CodeGen/RISCV/remat.ll
llvm/test/CodeGen/Thumb2/2010-02-11-phi-cycle.ll
llvm/test/CodeGen/Thumb2/LowOverheadLoops/mve-float-loops.ll
llvm/test/CodeGen/Thumb2/cbnz.ll
llvm/test/CodeGen/X86/mmx-coalescing.ll
llvm/test/CodeGen/X86/pr38795.ll
llvm/test/CodeGen/X86/ragreedy-hoist-spill.ll
llvm/test/CodeGen/X86/reverse_branches.ll
llvm/test/CodeGen/X86/shadow-stack.ll
llvm/test/CodeGen/X86/speculative-load-hardening.ll
llvm/test/CodeGen/X86/tail-dup-merge-loop-headers.ll
llvm/test/CodeGen/X86/tail-dup-repeat.ll
llvm/test/CodeGen/X86/tail-merge-after-mbp.mir
llvm/test/CodeGen/X86/tail-opts.ll