]> granicus.if.org Git - llvm/commit
[ModuloSchedule] Peel out prologs and epilogs, generate actual code
authorJames Molloy <jmolloy@google.com>
Wed, 2 Oct 2019 12:46:44 +0000 (12:46 +0000)
committerJames Molloy <jmolloy@google.com>
Wed, 2 Oct 2019 12:46:44 +0000 (12:46 +0000)
commit27fd3594bf6af51aad0f5b6223fe8cf295d76d7e
tree0a3454c391bb8ad24acfe32f4b578670fa2b8358
parent72b55d49c0f45921ffad85691ea6f5aeb1c4586b
[ModuloSchedule] Peel out prologs and epilogs, generate actual code

Summary:
This extends the PeelingModuloScheduleExpander to generate prolog and epilog code,
and correctly stitch uses through the prolog, kernel, epilog DAG.

The key concept in this patch is to ensure that all transforms are *local*; only a
function of a block and its immediate predecessor and successor. By defining the problem in this way
we can inductively rewrite the entire DAG using only local knowledge that is easy to
reason about.

For example, we assume that all prologs and epilogs are near-perfect clones of the
steady-state kernel. This means that if a block has an instruction that is predicated out,
we can redirect all users of that instruction to that equivalent instruction in our
immediate predecessor. As all blocks are clones, every instruction must have an equivalent in
every other block.

Similarly we can make the assumption by construction that if a value defined in a block is used
outside that block, the only possible user is its immediate successors. We maintain this
even for values that are used outside the loop by creating a limited form of LCSSA.

This code isn't small, but it isn't complex.

Enabled a bunch of testing from Hexagon. There are a couple of tests not enabled yet;
I'm about 80% sure there isn't buggy codegen but the tests are checking for patterns
that we don't produce. Those still need a bit more investigation. In the meantime we
(Google) are happy with the code produced by this on our downstream SMS implementation,
and believe it generates correct code.

Subscribers: mgorny, hiraditya, jsji, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373462 91177308-0d34-0410-b5e6-96231b3b80d8
61 files changed:
include/llvm/CodeGen/MachineLoopUtils.h [new file with mode: 0644]
include/llvm/CodeGen/ModuloSchedule.h
lib/CodeGen/CMakeLists.txt
lib/CodeGen/MachineLoopUtils.cpp [new file with mode: 0644]
lib/CodeGen/MachinePipeliner.cpp
lib/CodeGen/ModuloSchedule.cpp
test/CodeGen/Hexagon/pipeliner/swp-phi-start.mir
test/CodeGen/Hexagon/swp-art-deps-rec.ll
test/CodeGen/Hexagon/swp-bad-sched.ll
test/CodeGen/Hexagon/swp-carried-1.ll
test/CodeGen/Hexagon/swp-carried-dep1.mir
test/CodeGen/Hexagon/swp-carried-dep2.mir
test/CodeGen/Hexagon/swp-chain-refs.ll
test/CodeGen/Hexagon/swp-change-dep1.ll
test/CodeGen/Hexagon/swp-change-deps.ll
test/CodeGen/Hexagon/swp-check-offset.ll
test/CodeGen/Hexagon/swp-const-tc1.ll
test/CodeGen/Hexagon/swp-const-tc2.ll
test/CodeGen/Hexagon/swp-const-tc3.ll
test/CodeGen/Hexagon/swp-conv3x3-nested.ll
test/CodeGen/Hexagon/swp-copytophi-dag.ll
test/CodeGen/Hexagon/swp-dep-neg-offset.ll
test/CodeGen/Hexagon/swp-disable-Os.ll
test/CodeGen/Hexagon/swp-epilog-numphis.ll
test/CodeGen/Hexagon/swp-epilog-phi2.ll
test/CodeGen/Hexagon/swp-epilog-phi4.ll
test/CodeGen/Hexagon/swp-epilog-phi5.ll
test/CodeGen/Hexagon/swp-epilog-phi8.ll
test/CodeGen/Hexagon/swp-kernel-phi1.ll
test/CodeGen/Hexagon/swp-large-rec.ll
test/CodeGen/Hexagon/swp-listen-loop3.ll
test/CodeGen/Hexagon/swp-loop-carried-unknown.ll
test/CodeGen/Hexagon/swp-lots-deps.ll
test/CodeGen/Hexagon/swp-max.ll
test/CodeGen/Hexagon/swp-maxstart.ll
test/CodeGen/Hexagon/swp-memrefs-epilog.ll
test/CodeGen/Hexagon/swp-multi-loops.ll
test/CodeGen/Hexagon/swp-new-phi.ll
test/CodeGen/Hexagon/swp-order-copies.ll
test/CodeGen/Hexagon/swp-order-deps7.ll
test/CodeGen/Hexagon/swp-order.ll
test/CodeGen/Hexagon/swp-phi-ch-offset.ll
test/CodeGen/Hexagon/swp-phi-chains.ll
test/CodeGen/Hexagon/swp-phi-dep.ll
test/CodeGen/Hexagon/swp-phi-ref.ll
test/CodeGen/Hexagon/swp-pragma-disable.ii
test/CodeGen/Hexagon/swp-pragma-initiation-interval.ii
test/CodeGen/Hexagon/swp-prolog-phi.ll
test/CodeGen/Hexagon/swp-rename.ll
test/CodeGen/Hexagon/swp-resmii-1.ll
test/CodeGen/Hexagon/swp-resmii.ll
test/CodeGen/Hexagon/swp-reuse-phi-6.ll
test/CodeGen/Hexagon/swp-sigma.ll
test/CodeGen/Hexagon/swp-stages4.ll
test/CodeGen/Hexagon/swp-stages5.ll
test/CodeGen/Hexagon/swp-subreg.ll
test/CodeGen/Hexagon/swp-swap.ll
test/CodeGen/Hexagon/swp-tfri.ll
test/CodeGen/Hexagon/swp-vect-dotprod.ll
test/CodeGen/Hexagon/swp-vmult.ll
test/CodeGen/Hexagon/swp-vsum.ll