SPRUIV4D May 2020 – May 2024
In some cases, the compiler can reduce the minimum safe iteration count of a software pipelined loop through a transformation called stage collapsing. Information on stage collapsing is displayed in the Software Pipeline Information comment block. An example is shown below.
Stage collapsing always helps reduce code size. Stage collapsing is usually beneficial for performance, because it can lower the minimum safe iteration count for the software pipelined loop so that when the loop executes only a small number of times, it is more likely the (faster) software pipelined loop can be executed and execution does not have to be transferred to the duplicate loop (which is slower and not-software pipelined).
;* Epilog not entirely removed
;* Collapsed epilog stages : 2
;*
;* Prolog not removed
;* Collapsed prolog stages : 0
;*
;* Max amt of load speculation : 128 bytes
;*
;* Minimum safe iteration count : 3 (after unrolling)
The feedback in the example above shows that two epilog stages were collapsed. However, the compiler was not able to collapse any prolog stages and thus was not able to reduce the minimum safe iteration count of the software pipelined loop down to one (which is the best-case). There are complex technical reasons why a software pipelined loop prolog or epilog may not be removed, and it is difficult for a programmer to affect this outcome.
When performing stage collapsing, the compiler may generate code that executes load instructions speculatively, meaning that the result of the load might not be used. In cases where the compiler needs to speculatively execute load instructions, it only does so with load instructions that will not cause an exception if the address accessed is outside the range of legal memory. The feedback about "Max amt of load speculation" tells you how far outside the range of normal address accesses the load speculation will access.