[LLVMdev] Question regarding basic-block placement optimization

Andrew Trick 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:
> 
> A:
>   br B(80%), C(20%)
> B:
>   br D
> C:
>   br D(90%), E(10%)
> D:
>   br F
> E:
>   br F
> F:
>   ret
> 
> 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.

Andy 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111023/6afe4f1b/attachment.html>


More information about the llvm-dev mailing list