Hello folks,<div><br></div><div>This is an attempt to fix PR13265 and remove a FIXME and real wart on the machine block placement strategy.</div><div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div>Does this initial step look good?</div><div><br></div><div>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...</div>
<div>-Chandler</div>