Bidirectional Scheduling: A New Global Code Scheduling Approach

Instruction scheduling is an important compiler code transformation step for generating code for pipelined and VLIW processors. Dependencies among instructions need to be enforced. In this paper, we describe a global code scheduling algorithm that moves instructions upward and downward in the control flow graph. Downward code motion is first applied. The purpose of downward code motion is to move store instructions and other instructions on the tail portion of critical paths to later basic blocks. This allows for better code compaction. After downward code motion is applied, upward code motion and code compaction are applied. Upward code motion moves instructions on the beginning portion of critical paths to preceding basic blocks. This allows for better code compaction. In our algorithm, we integrate some instruction-level parallelization techniques with upward code motion to permit more code motion freedom.