GCC offers a number of options related to instruction scheduling in the compiler flags. An overview of what this means is on the GCC Wiki for “Instruction Scheduling”, but this is well out of date (last updated in 2008). I understand the general idea: allow the compiler to re-order instructions to avoid stalls / achieve better CPU resource usage. The details on the knobs to control this are severely lacking and highly technical, though.
Here’s the options that (I think) relate to instruction scheduling, from the current GCC Optimization Options:
- Modulo Scheduling
-fmodulo-sched
- “Perform swing modulo scheduling immediately before the first scheduling pass…”
-fmodulo-sched-allow-regmoves
,-freschedule-modulo-scheduled-loops
- (related to above)
- Instruction Scheduling (Haifa?)
-fschedule-insns
,-fschedule-insns2
- “…attempt to reorder instructions to eliminate execution stalls due to required data being unavailable.”
-fsched-pressure
- “Enable register pressure sensitive insn scheduling before register allocation.”
-fsched-spec-load
,-fsched-spec-load-dangerous
,-f[no-]sched-spec
- “Allow speculative motion of … load instructions”
-fsched2-use-superblocks
- “When scheduling after register allocation, use superblock scheduling … This option is experimental”
-f[no-]sched-interblock
,-fsched-stalled-insns
,-fsched-stalled-insns-dep
,-fsched-*-heuristic
- (related to above)
- Selective Scheduler
-fselective-scheduling
,-fselective-scheduling2
- “Schedule instructions using selective scheduling algorithm. Selective scheduling runs instead of the (first/second) scheduler pass.”
-fsel-sched-pipelining
,-fsel-sched-pipelining-outer-loops
- (related to above)
- Others
-frename-registers
,-fschedule-fusion
,-param sched-pressure-algorithm=?
- various other effects
And, of course, the multiple optimization level (-O2
, -O3
, -Os
etc) also enable some of these by default.
Time for questions.
- What is the difference between these? Is one “better” than the other, more costly in compile time, experimental, limited to only certain targets, etc?
- What are the limits of enabling these? e.g. can Modulo Scheduling be turned on with the Selective Scheduler? or are they mutually exclusive?
- Where can I find more documentation about this? As I’ve seen the GCC manual and wiki are both light on information, and searches haven’t turned up much more about this topic either. Short of reading commit messages to a mailing list, how would a user (me) learn about what these options do?
- Anything else? In this “I don’t know what I don’t know” situation… what should I know? 🙂