Compilers
What is the main purpose of instruction scheduling in a compiler?
- AReducing the instruction count by any means, even if program results change
- BReordering without changing results to fill latencies
- CRearranging instructions into the order chosen by the OS scheduler
Show answer and explanation
Answer: B. Reordering without changing results to fill latencies
When a load or multiply result is not immediately available, placing its consumer right after it stalls the CPU. Instruction scheduling reorders instructions, respecting data dependences so results are unchanged, to insert independent instructions in between and make use of the waiting time. It is especially effective on in-order CPUs. Transformations that change results are not allowed, and the OS scheduler decides process switching, a separate mechanism.
- A. Transformations that change results are not allowed.
- B. Correct. It reorders within dependences to fill latencies.
- C. The OS scheduler decides process switching, a separate mechanism.