[PATCH] D16829: An implementation of Swing Modulo Scheduling

mattias.v.eriksson@ericsson.com via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 11:11:11 PST 2016

materi added inline comments.

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,
bcahoon wrote:
> 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. 
Thank you! I think I understand how it works now. The prolog and epilog blocks are not the "bundles" of the SWP prolog and epilog. The jump label for my trip count = 1 case is put in the middle of the first "epilog bundle".

But what if there are loop carried 0-latency dependences in the graph? This will force a certain order within the kernel to allow correct bundling in a later step. Can this be handled?


More information about the llvm-commits mailing list