CmmPipeline: add a second pass of CmmCommonBlockElim
Concern Raisedd5c4d46a62ce

Authored by michalt on Mar 26 2018, 2:18 PM.


CmmPipeline: add a second pass of CmmCommonBlockElim

The sinking pass often gets rid of unnecessary registers
registers/assignements exposing more opportunities for CBE, so this
commit adds a second round of CBE after the sinking pass and should
fix Trac #12915 (and some examples in Trac #14226).

Nofib results:

  • Binary size: 0.9% reduction on average
  • Compile allocations: 0.7% increase on average
  • Runtime: noisy, two separate runs of nofib showed a tiny reduction on average, (~0.2-0.3%), but I think this is mostly noise
  • Compile time: very noisy, but generally within +/- 0.5% (one run faster, one slower)

One interesting part of this change is that running CBE invalidates
results of proc-point analysis. But instead of re-doing the whole
analysis, we can use the map that CBE creates for replacing/comparing
block labels (maps a redundant label to a useful one) to update the
results of proc-point analysis. This lowers the overhead compared to the
previous experiment in Trac #12915.

Signed-off-by: Michal Terepeta <>

Test Plan: ./validate

Reviewers: bgamari, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: Trac #12915, Trac #14226

Differential Revision: