[LLVMdev] Question regarding basic-block placement optimization
atrick at apple.com
Sun Oct 23 11:45:09 PDT 2011
On Oct 23, 2011, at 1:11 AM, Chandler Carruth <chandlerc at google.com> wrote:
> Let me give you a little example to think about:
> br B(80%), C(20%)
> br D
> br D(90%), E(10%)
> br F
> br F
> This is a fine topological sort but bad layout based on expected
> branch probability (even with low confidence in the profile).
> The only good layout that preserves topological ordering is:
> A, B, C, E, D, F
> I made a test case out of this, and I think it works. It's a bit confusing at it just replaces branches to F with ret. That removes the edge from D to F, and makes the following ordering also viable: A, B, C, D, E. That's the ordering it chooses, and it also duplicates D up into B instead of branching from B to D. :: shrug ::. It looks pretty good to me though. =]
Great. I didn't expect it to work as test case without tweaking. The case when no blocks get folded or tail duped is interesting. You'll have to disable those codegen optimizations or just add blocks and instructions until they're defeated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev