This is an archive of the discontinued LLVM Phabricator instance.

[PassManagerBuilder] Add a few more scalar optimization passes
ClosedPublic

Authored by jmolloy on Dec 11 2015, 6:00 AM.

Details

Summary

This patch does two things:

  1. mem2reg is now run immediately after globalopt. Now that globalopt can localize variables more aggressively, it makes sense to lower them to SSA form earlier rather than later so they can benefit from the full set of optimization passes.
  2. More scalar optimizations are run after the loop optimizations in LTO mode. The loop optimizations (especially indvars) can clean up scalar code sufficiently to make it worthwhile running more scalar passes. I've particularly added SCCP here as it isn't run anywhere else in the LTO pass pipeline.

Mem2reg is super cheap and shouldn't affect compilation time at all. The
rest of the added passes are in the LTO pipeline only so doesn't affect
the vast majority of compilations, just the link step.

Diff Detail

Event Timeline

jmolloy updated this revision to Diff 42517.Dec 11 2015, 6:00 AM
jmolloy retitled this revision from to [PassManagerBuilder] Add a few more scalar optimization passes.
jmolloy updated this object.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
hfinkel added inline comments.Dec 11 2015, 6:13 AM
lib/Transforms/IPO/PassManagerBuilder.cpp
568

I'm somewhat biased here, but I recommend using createBitTrackingDCEPass() instead. It should be a pure superset of ADCE (and a bit more powerful).

jmolloy added inline comments.Dec 11 2015, 6:31 AM
lib/Transforms/IPO/PassManagerBuilder.cpp
568

SGTM, I'm perfectly happy to do that!

mehdi_amini edited edge metadata.Dec 11 2015, 8:07 AM

Hi James,

A few points:

  • I'd rather see this as two patches: one for the GlobalOpt and the other for the scalar optimizations
  • Do you have benchmark results before/after?
  • See also: http://reviews.llvm.org/D13443 ; I paused my work on this till January because of the ThinLTO bringup, but I still plan to move forward with it.

Thanks!

hfinkel edited edge metadata.Dec 11 2015, 9:52 AM

Also, as a general note, we should make sure these various passes preserve GlobalsAA (as not to undo the effects of r255348).

jmolloy updated this revision to Diff 42825.Dec 15 2015, 1:26 AM
jmolloy edited edge metadata.
jmolloy removed rL LLVM as the repository for this revision.

Act on Hal's comments.

mehdi_amini accepted this revision.Jan 2 2016, 9:25 PM
mehdi_amini edited edge metadata.

Committed in r255634

This revision is now accepted and ready to land.Jan 2 2016, 9:25 PM
mehdi_amini closed this revision.Jan 2 2016, 9:25 PM