[PATCH] D68205: [ModuloSchedule] Peel out prologs and epilogs, generate actual code

James Molloy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 03:53:57 PDT 2019


jmolloy created this revision.
Herald added subscribers: llvm-commits, jsji, hiraditya, mgorny.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68205

Files:
  llvm/include/llvm/CodeGen/MachineLoopUtils.h
  llvm/include/llvm/CodeGen/ModuloSchedule.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/MachineLoopUtils.cpp
  llvm/lib/CodeGen/MachinePipeliner.cpp
  llvm/lib/CodeGen/ModuloSchedule.cpp
  llvm/test/CodeGen/Hexagon/pipeliner/swp-phi-start.mir
  llvm/test/CodeGen/Hexagon/swp-art-deps-rec.ll
  llvm/test/CodeGen/Hexagon/swp-bad-sched.ll
  llvm/test/CodeGen/Hexagon/swp-carried-1.ll
  llvm/test/CodeGen/Hexagon/swp-carried-dep1.mir
  llvm/test/CodeGen/Hexagon/swp-carried-dep2.mir
  llvm/test/CodeGen/Hexagon/swp-chain-refs.ll
  llvm/test/CodeGen/Hexagon/swp-change-dep1.ll
  llvm/test/CodeGen/Hexagon/swp-change-deps.ll
  llvm/test/CodeGen/Hexagon/swp-check-offset.ll
  llvm/test/CodeGen/Hexagon/swp-const-tc1.ll
  llvm/test/CodeGen/Hexagon/swp-const-tc2.ll
  llvm/test/CodeGen/Hexagon/swp-const-tc3.ll
  llvm/test/CodeGen/Hexagon/swp-conv3x3-nested.ll
  llvm/test/CodeGen/Hexagon/swp-copytophi-dag.ll
  llvm/test/CodeGen/Hexagon/swp-dep-neg-offset.ll
  llvm/test/CodeGen/Hexagon/swp-disable-Os.ll
  llvm/test/CodeGen/Hexagon/swp-epilog-numphis.ll
  llvm/test/CodeGen/Hexagon/swp-epilog-phi2.ll
  llvm/test/CodeGen/Hexagon/swp-epilog-phi4.ll
  llvm/test/CodeGen/Hexagon/swp-epilog-phi5.ll
  llvm/test/CodeGen/Hexagon/swp-epilog-phi8.ll
  llvm/test/CodeGen/Hexagon/swp-kernel-phi1.ll
  llvm/test/CodeGen/Hexagon/swp-large-rec.ll
  llvm/test/CodeGen/Hexagon/swp-listen-loop3.ll
  llvm/test/CodeGen/Hexagon/swp-loop-carried-unknown.ll
  llvm/test/CodeGen/Hexagon/swp-lots-deps.ll
  llvm/test/CodeGen/Hexagon/swp-max.ll
  llvm/test/CodeGen/Hexagon/swp-maxstart.ll
  llvm/test/CodeGen/Hexagon/swp-memrefs-epilog.ll
  llvm/test/CodeGen/Hexagon/swp-multi-loops.ll
  llvm/test/CodeGen/Hexagon/swp-new-phi.ll
  llvm/test/CodeGen/Hexagon/swp-order-copies.ll
  llvm/test/CodeGen/Hexagon/swp-order-deps7.ll
  llvm/test/CodeGen/Hexagon/swp-order.ll
  llvm/test/CodeGen/Hexagon/swp-phi-ch-offset.ll
  llvm/test/CodeGen/Hexagon/swp-phi-chains.ll
  llvm/test/CodeGen/Hexagon/swp-phi-dep.ll
  llvm/test/CodeGen/Hexagon/swp-phi-ref.ll
  llvm/test/CodeGen/Hexagon/swp-pragma-disable.ii
  llvm/test/CodeGen/Hexagon/swp-pragma-initiation-interval.ii
  llvm/test/CodeGen/Hexagon/swp-prolog-phi.ll
  llvm/test/CodeGen/Hexagon/swp-rename.ll
  llvm/test/CodeGen/Hexagon/swp-resmii-1.ll
  llvm/test/CodeGen/Hexagon/swp-resmii.ll
  llvm/test/CodeGen/Hexagon/swp-reuse-phi-6.ll
  llvm/test/CodeGen/Hexagon/swp-sigma.ll
  llvm/test/CodeGen/Hexagon/swp-stages4.ll
  llvm/test/CodeGen/Hexagon/swp-stages5.ll
  llvm/test/CodeGen/Hexagon/swp-subreg.ll
  llvm/test/CodeGen/Hexagon/swp-swap.ll
  llvm/test/CodeGen/Hexagon/swp-tfri.ll
  llvm/test/CodeGen/Hexagon/swp-vect-dotprod.ll
  llvm/test/CodeGen/Hexagon/swp-vmult.ll
  llvm/test/CodeGen/Hexagon/swp-vsum.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68205.222385.patch
Type: text/x-patch
Size: 55224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190930/e2a24e5f/attachment-0001.bin>


More information about the llvm-commits mailing list