[PATCH] D28593: Update loop branch_weight metadata after loop rotation.

Xin Tong via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 13 09:21:36 PST 2017


On Fri, Jan 13, 2017 at 7:36 AM, Dehao Chen via Phabricator
<reviews at reviews.llvm.org> wrote:
> danielcdh added a comment.
>
> Looks like this patch will make the "always call" worse:
>
> Without this patch:
>
>   pushq   %rbx
>   movq    %rdi, %rbx
>   cmpl    $0, (%rbx)
>   jne     .LBB1_3
>
> .LBB1_1:                                # =>This Inner Loop Header: Depth=1
>
>   movq    %rbx, %rdi
>   callq   call_me
>   cmpl    $0, (%rbx)
>   je      .LBB1_1
>
> .LBB1_3:
>
>   popq    %rbx
>   retq
>
> With this patch:
>
>   pushq   %rbx
>   movq    %rdi, %rbx
>   cmpl    $0, (%rbx)
>   je      .LBB1_1
>
> .LBB1_3:
>
>   popq    %rbx
>   retq
>
> .LBB1_1:                                # =>This Inner Loop Header: Depth=1
>
>   movq    %rbx, %rdi
>   callq   call_me
>   cmpl    $0, (%rbx)
>   jne     .LBB1_3
>   jmp     .LBB1_1
>
> As the trip count of this loop is always 1, the first code will have no taken branches, while with this patch, it will have 2 taken branches.
>
>
> https://reviews.llvm.org/D28593
>
>
>

Sorry there is a mistaken updating the branch weight for the guard
block. I fixed it. what i said before still hold true.
-Xin


More information about the llvm-commits mailing list