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

Chandler Carruth chandlerc at gmail.com
Mon Jul 16 06:24:47 PDT 2012


Hello folks,

This is an attempt to fix PR13265 and remove a FIXME and real wart on the
machine block placement strategy.

The current algorithm used for aligning basic blocks is essentially bogus.
It aligns "back" edges with no real consideration of whether this is a good
or bad thing. 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120716/29fe68cf/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr13265.patch
Type: application/octet-stream
Size: 6560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120716/29fe68cf/attachment.obj>


More information about the llvm-commits mailing list