]> granicus.if.org Git - llvm/commit
Codegen: Tail-duplicate during placement.
authorKyle Butt <kyle+llvm@iteratee.net>
Fri, 7 Oct 2016 22:33:20 +0000 (22:33 +0000)
committerKyle Butt <kyle+llvm@iteratee.net>
Fri, 7 Oct 2016 22:33:20 +0000 (22:33 +0000)
commit71c312652c10f1855b28d06697c08d47e7a243e4
treefc47a8d79ab79a61a74938687ef1390de829bfbf
parentc4f04d97264064ab93549af1e6dd776246411675
Codegen: Tail-duplicate during placement.

The tail duplication pass uses an assumed layout when making duplication
decisions. This is fine, but passes up duplication opportunities that
may arise when blocks are outlined. Because we want the updated CFG to
affect subsequent placement decisions, this change must occur during
placement.

In order to achieve this goal, TailDuplicationPass is split into a
utility class, TailDuplicator, and the pass itself. The pass delegates
nearly everything to the TailDuplicator object, except for looping over
the blocks in a function. This allows the same code to be used for tail
duplication in both places.

This change, in concert with outlining optional branches, allows
triangle shaped code to perform much better, esepecially when the
taken/untaken branches are correlated, as it creates a second spine when
the tests are small enough.

Issue from previous rollback fixed, and a new test was added for that
case as well. Issue was worklist/scheduling/taildup issue in layout.

Issue from 2nd rollback fixed, with 2 additional tests. Issue was
tail merging/loop info/tail-duplication causing issue with loops that share
a header block.

Differential revision: https://reviews.llvm.org/D18226

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283619 91177308-0d34-0410-b5e6-96231b3b80d8
24 files changed:
include/llvm/Analysis/LoopInfoImpl.h
include/llvm/CodeGen/TailDuplicator.h
lib/CodeGen/MachineBlockPlacement.cpp
lib/CodeGen/TailDuplication.cpp
lib/CodeGen/TailDuplicator.cpp
test/CodeGen/AArch64/arm64-extload-knownzero.ll
test/CodeGen/AArch64/machine_cse.ll
test/CodeGen/AArch64/tail-dup-repeat-worklist.ll [new file with mode: 0644]
test/CodeGen/ARM/2011-03-23-PeepholeBug.ll
test/CodeGen/PowerPC/branch-opt.ll
test/CodeGen/PowerPC/sjlj.ll
test/CodeGen/PowerPC/tail-dup-layout.ll [new file with mode: 0644]
test/CodeGen/WebAssembly/cfg-stackify.ll
test/CodeGen/WebAssembly/mem-intrinsics.ll
test/CodeGen/X86/block-placement.ll
test/CodeGen/X86/cmov-into-branch.ll
test/CodeGen/X86/fma-intrinsics-phi-213-to-231.ll
test/CodeGen/X86/fp-une-cmp.ll
test/CodeGen/X86/pr11202.ll
test/CodeGen/X86/ragreedy-bug.ll
test/CodeGen/X86/sse1.ll
test/CodeGen/X86/tail-dup-merge-loop-headers.ll [new file with mode: 0644]
test/CodeGen/X86/tail-dup-repeat.ll [new file with mode: 0644]
test/CodeGen/X86/update-terminator.mir