This is an archive of the discontinued LLVM Phabricator instance.

Enable Loop Sink pass for functions that has profile.
ClosedPublic

Authored by danielcdh on Oct 31 2016, 9:29 AM.

Details

Summary

For functions with profile data, we are confident that loop sink will be optimal in sinking code.

Event Timeline

danielcdh updated this revision to Diff 76430.Oct 31 2016, 9:29 AM
danielcdh retitled this revision from to Enable Loop Sink pass for functions that has profile..
danielcdh updated this object.
danielcdh added reviewers: hfinkel, davidxl.
danielcdh added a subscriber: llvm-commits.
hfinkel accepted this revision.Nov 8 2016, 4:14 PM
hfinkel edited edge metadata.

LGTM

lib/Transforms/Scalar/LoopSink.cpp
246

Please add a comment here explaining why you're doing this.

This revision is now accepted and ready to land.Nov 8 2016, 4:14 PM
danielcdh closed this revision.Nov 8 2016, 5:07 PM
This revision was automatically updated to reflect the committed changes.
mzolotukhin added inline comments.Nov 9 2016, 4:51 PM
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
650 ↗(On Diff #77293)

Can't we schedule this right after LICM?
I think we're placing LoopSinking in a separate instance of loop pass manager - is that what we want?

davidxl added inline comments.Nov 9 2016, 5:09 PM
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
650 ↗(On Diff #77293)

LICM also serves as an IR canonicalization pass that enables other optimization, so loopSinking needs to be a very late IR pass to avoid undoing LICM result too early. Otherwise the logic of loopSinking can be baked into LICM as proposed originally.

mehdi_amini added inline comments.Nov 9 2016, 5:11 PM
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
650 ↗(On Diff #77293)

Can we have a comment here, the PassManagerBuilder is already hard to follow, it'd be great to bake in why passes are there, and why they are where they are.

mzolotukhin added inline comments.Nov 9 2016, 5:36 PM
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
650 ↗(On Diff #77293)

I meant the last invocation of LICM, which is also very late (before createAlignmentFromAssumptionsPass). I don't see any loop pass in between them now. But anyway, I just wanted to make sure this placement is conscious, so if this is the case, I'm ok with it. And as Mehdi said, comments would be helpful here.

Comments added:

r286480 | dehao | 2016-11-10 09:42:18 -0800 (Thu, 10 Nov 2016) | 2 lines

Add comments about why we put LoopSink pass at the very late stage.