Zdenek Dvorak wrote:
*sched* -- no idea what happens there; it seems to make REG_SAVE_NOTE notes from loop notes, and then makes some magic, but I do not understand what and why.
The loop notes are converted into REG_NOTES, and attached to an adjacent instruction. The REG_SAVE_NOTES are treated as scheduling barriers. Nothing is allowed to move forwards and backwards across them. After scheduling, the REG_SAVE_NOTES are converted back to loop notes. This ensures that loop structure is preserved by the instruction scheduler. All insns inside the loop before sched will still be inside the loop after sched. All insns outside the loop before sched will still be outside the loop after sched.
The reason for doing this is because some of the register lifetime info computed by flow is loop dependent. For instance, reg_n_refs is multiplied by a constant factor if a use occurs inside a loop. This ensures the registers used inside a loop are more likely to get a hard register than pseudo registers used outside a loop. However, a side effect of this means that the scheduler either has to preserve loop structure to prevent the numbers from getting out of whack, or else we need to recompute flow info after sched. The decision was made long ago to preserve loop structure.
This is my recollection of how and why things work they do. My recollection could be wrong and/or out-of-date.
I see that flow no longer uses loop_depth when computing REG_N_REFS, so the original reason for the sched support seems to be gone.
-- Jim Wilson, GNU Tools Support, http://www.specifix.com