Page MenuHomePhabricator

Global code motion of congruent computations
Needs ReviewPublic

Authored by hiraditya on Apr 17 2017, 2:34 PM.

Details

Summary

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%).

Diff Detail

Event Timeline

hiraditya created this revision.Apr 17 2017, 2:34 PM
hiraditya updated this revision to Diff 96800.Apr 26 2017, 11:59 AM

Sink to immediate successors, update memory SSA when sinking.

hiraditya edited the summary of this revision. (Show Details)Apr 26 2017, 12:07 PM
mehdi_amini added inline comments.
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
140

Is it intended to be part of this patch?

482

Can you clarify why is it inserted here? It seems like a strange place to me

hiraditya added inline comments.Apr 27 2017, 11:43 AM
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
140

No, I'll remove this.

482

I'll remove this as well, this was for my testing.

Plesse try to add more reviewers. This seems to be very promising.

Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2019, 4:00 PM

Working on porting this to latest llvm, will push the latest changes soon.