epilogue Before getting to the prologue and epilogue, which handle iterations at the beginning and end of the loop, let's verify that this code does the same thing as the original for iterations in the middle of the loop. Specifically, consider iteration 7 in the original loop. The first iteration of the pipelined loop will be the first iteration that includes an instruction from iteration 7 of the original loop. The sequence of instructions is: Iteration 1: A(7) B(6) C(5) D(3) E(2) F(1) Iteration 2: A(8) B(7) C(6) D(4) E(3) F(2) Iteration 3: A(9) B(8) C(7) D(5) E(4) F(3) Iteration 4: A(10) B(9) C(8) D(6) E(5) F(4) Iteration 5: A(11) B(10) C(9) D(7) E(6) F(5) Iteration 6: A(12) B(11) C(10) D(8) E(7) F(6) Iteration 7: A(13) B(12) C(11) D(9) E(8) F(7) However, unlike the original loop, the pipelined version avoids the bottleneck at instruction C. Note that there are 12 instructions between C(7) and the dependent instruction D(7), which means that the latency cycles of instruction C(7) are used for other instructions instead of being wasted. The prologue and epilogue handle iterations at the beginning and end of the loop. Here is a possible prologue for our example above: ; loop prologue (arranged on lines for clarity) A(1) A(2), B(1) A(3), B(2), C(1) A(4), B(3), C(2) ; cannot start D(1) yet A(5), B(4), C(3), D(1) A(6), B(5), C(4), D(2), E(1) Each line above corresponds to an iteration of the main pipelined loop, but without the instructions for iterations that have not yet begun. Similarly, the epilogue progressively removes instructions for iterations that have completed: ; loop epilogue (arranged on lines for clarity) B(bignumber), C(bignumber-1), D(bignumber-3), E(bignumber-4), F(bignumber-5) C(bignumber), D(bignumber-2), E(bignumber-3), F(bignumber-4) D(bignumber-1), E(bignumber-2), F(bignumber-3) D(bignumber), E(bignumber-1), F(bignumber-2) E(bignumber), F(bignumber-1) F(bignumber) Difficulties of implementation The requirement of a prologue and epilogue is one of the major difficulties of implementing software pipelining. Note that the prologue in this example is 18 instructions, 3 times as large as the loop itself. The epilogue would also be 18 instructions. In other words, the prologue and epilogue together are 6 times as large as the loop itself. While still better than attempting loop unrolling for this example, software pipelining requires a trade-off between speed and memory usage. Keep in mind, also, that if the code bloat is too large, it will affect speed anyway via a decrease in cache performance. A further difficulty is that