This is an early work here for tracking changes. Feedback are most welcome.
This patch implements Global Code Motion (GCM) compiler optimization which schedules congruent
instructions across the program. This is an extension of GVNHoist. Not only GCM saves code size, it exposes
redundancies in some cases, it exposes more instruction level parallelism in the
basic-block to which instructions are moved, and it enables other passes like
loop invariant motion to remove more redundancies. The cost model to drive the
code motion is based on liveness analysis on SSA representation such that the
(virtual) register pressure does not increase resulting in 2% fewer spills on
the SPEC-2006 benchmark suite when compiled for x86_64-linux.
The experimental results show reduction in the total compilation time by 1% on SPEC. GCM enables more
inlining and exposes more loop invariant code motion opportunities in majority
of the benchmarks. We have also seen execution time improvements in a few of
SPEC benchmarks viz. mcf (3%) and sjeng(2%).