This is an archive of the discontinued LLVM Phabricator instance.

[MBP] Factor out the optimizations on branch conditions and unanalyzable branches. NFCI.
ClosedPublic

Authored by haicheng on May 11 2016, 11:36 AM.

Details

Summary

Factor out two optimizations into a new function. Cut, paste and rename a variable.

This is another part of the effort of enabling tail merging in the block placement. Tail merging can reverse the branch conditions even if it does not merge any tails. So, I need to optimize the conditions afterwards.

Besides above, other benefits of this patch are

  • We call AnalyzeBranch() to optimize unanalyzable branches, but the result of AnalyzeBranch() is not used. Now the result is useful.
  • Before the layout of all the MBBs is set, the result of AnalyzeBranch() is not correct and needs to be fixed before using it to optimize the branch conditions. Now this optimization is called after the layout, the code used to fix the result of AnalyzeBranch() is not needed.
  • The branch condition of the last block is not optimized before this patch. Now it is optimized.

Diff Detail

Repository
rL LLVM

Event Timeline

haicheng updated this revision to Diff 56941.May 11 2016, 11:36 AM
haicheng retitled this revision from to [MBP] Factor out the optimizations on branch conditions and unanalyzable branches. NFCI. .
haicheng updated this object.
haicheng set the repository for this revision to rL LLVM.
haicheng updated this object.May 11 2016, 11:45 AM
haicheng added reviewers: mcrosier, gberry, mssimpso.
haicheng added subscribers: qcolombet, iteratee, hfinkel and 2 others.

Overall, looks good. Letting time for other to review.

lib/CodeGen/MachineBlockPlacement.cpp
1313 ↗(On Diff #56941)

I'd keep the block here. While not strictly necessary, the comment is quite long and so it makes things clearer IMO.

haicheng updated this revision to Diff 56995.May 11 2016, 9:14 PM

Address Amaury's comments. Thank you, Amaury.

haicheng marked an inline comment as done.May 11 2016, 9:14 PM

Ok it doesn't looks liek anyone has objections. Let get the details nailed and merge this.

lib/CodeGen/MachineBlockPlacement.cpp
1323 ↗(On Diff #56995)

Part of this comment should be moved with the code.

haicheng updated this revision to Diff 57359.May 16 2016, 9:20 AM

Thank you very much, Amaury.

This chunk of the comment is a warning sign of using AnalyzeBranch(). Now I move it before calling AnalyzeBranch() and add some new comments about how to correctly use AnalyzeBranch() before the layout is set.

deadalnix accepted this revision.May 23 2016, 10:39 AM
deadalnix added a reviewer: deadalnix.

Ok let's go for that one. It doesn't looks like anyone has objections to it.

This revision is now accepted and ready to land.May 23 2016, 10:39 AM
This revision was automatically updated to reflect the committed changes.