[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:36:10 PST 2017


On Fri, Jan 13, 2017 at 9:34 AM, Dehao Chen <danielcdh at gmail.com> wrote:
> OK, but the with the new patch, the generated assembly file is identical
> with the assembly generated by a clean compiler (without the patch).
>
> Dehao

Yes, there is something in branchfolding in llc that folds away some
of the branches. I am looking at why.

-Xin
>
> On Fri, Jan 13, 2017 at 9:21 AM, Xin Tong <trent.xin.tong at gmail.com> wrote:
>>
>> 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