[PATCH] D16829: An implementation of Swing Modulo Scheduling

Brendon Cahoon via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 07:23:21 PST 2016


bcahoon added a comment.

We have considered adding bundles much earlier in the back-end, but I think that means changing the register allocator (and other passes) to work on bundles. It's been on our list of things to attempt, but we haven't done it yet. We've worked around the major problems of not having bundles in the pipeliner by carefully ordering the pipelined instructions, though it's not the ideal solution.


================
Comment at: lib/CodeGen/MachinePipeliner.cpp:3057-3059
@@ +3056,5 @@
+
+// Create branches from each prolog basic block to the appropriate epilog
+// block.  These edges are needed if the loop ends before reaching the
+// kernel.
+void SwingSchedulerDAG::addBranches(MBBVectorTy &PrologBBs,
----------------
materi wrote:
> I do not understand how this works when more than one iteration starts to execute in the prolog.
> 
> For example if the runtime trip count is 1, and 2 iterations are started in the prolog. Don't you miss executing some instructions from the only loop iteration?
> 
> If this is not a bug, maybe you can add a test case that shows how this works?
If two iterations are started in the prolog, then we generate two prolog basic blocks, and two epilog basic blocks.  At the end of each prolog basic block, we add a compare and branch to the corresponding epilog basic block (the fall through is to the next prolog block or the kernel).  This means that the first prolog block contains instructions from stage 0 and the second prolog block contains instructions from stage 1 and the 2nd iteration of stage 0.

In your example, with a run-time trip count of 1, the first prolog block branches to the last epilog block, and the instructions in the last epilog block are the first iteration of instructions scheduled in stage 1 and stage 2.

The swp-max.ll test case shows a pipelined schedule with 2 prolog and epilog blocks. 


http://reviews.llvm.org/D16829





More information about the llvm-commits mailing list