[llvm-commits] PATCH: Change the strategy for aligning branch targets during MachineBlockPlacement

Andrew Trick atrick at apple.com
Mon Jul 23 20:34:56 PDT 2012


On Jul 16, 2012, at 6:24 AM, Chandler Carruth <chandlerc at gmail.com> wrote:

>  Attached is a patch that instead walks the blocks and considers various aspects of the layout and the probabilities to decide whether aligning the block is likely to be profitable. It uses completely arbitrary heuristics which happen to produce results similar to the previous results, but with specific fixes to obviously ridiculous alignment such as reported in the PR.
> 
> It errs slightly in the direction of aligning fewer branch targets. To my mind this is the correct slant because alignment introduces significant code bloat and Agners tells me to be very judicious in aligning things as it rarely makes a large difference. If anything, I'd like to make this *more* conservative, but I'd rather take baby steps.
> 
> Does this initial step look good?
> 
> Thoughts about how far to go here? I have a follow-up patch that makes the whole thing tunable with a commandline flag. I can apply that and run some in depth benchmarks, but I suspect that the patch as-is already represents a strict improvement over the status quo...
> -Chandler

This looks like a good improvement. I'm not used to determining alignment without knowing instruction sizes and the actual alignment cost... But your approach makes sense.

+    // If the block is cold relative to its loop header, don't align it
+    // regardless of what edges into the block exist.

What if it's cold relative to its outer loop, or parent function? Cold code can have nested loops. If you can get away with frequency relative to function entry and layout predecessor, then you don't need LoopInfo here.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120723/d6ba2026/attachment.html>


More information about the llvm-commits mailing list