[Bug ipa/95790] Incorrect static target dispatch

yyc1992 at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Jun 20 19:26:16 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95790

--- Comment #3 from Yichao Yu <yyc1992 at gmail dot com> ---
And the assembly showing the correct dispatch is


        .file   "a.c"
        .text
        .p2align 4
        .type   _ZL3fooPKcj, @function
_ZL3fooPKcj:
.LFB0:
        .cfi_startproc
        movl    $1, %eax
        ret
        .cfi_endproc
.LFE0:
        .size   _ZL3fooPKcj, .-_ZL3fooPKcj
        .p2align 4
        .type   _ZL3fooPKcj.avx, @function
_ZL3fooPKcj.avx:
.LFB1:
        .cfi_startproc
        movl    $2, %eax
        ret
        .cfi_endproc
.LFE1:
        .size   _ZL3fooPKcj.avx, .-_ZL3fooPKcj.avx
        .p2align 4
        .type   _ZL3fooPKcj.avx512f, @function
_ZL3fooPKcj.avx512f:
.LFB2:
        .cfi_startproc
        movl    $3, %eax
        ret
        .cfi_endproc
.LFE2:
        .size   _ZL3fooPKcj.avx512f, .-_ZL3fooPKcj.avx512f
        .section        .text.unlikely,"ax",@progbits
.LCOLDB0:
        .text
.LHOTB0:
        .p2align 4
        .type   _ZL3fooPKcj.resolver, @function
_ZL3fooPKcj.resolver:
.LFB6:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        call    __cpu_indicator_init@PLT
        movq    __cpu_model@GOTPCREL(%rip), %rax
        movl    12(%rax), %eax
        testb   $-128, %ah
        je      .L8
        leaq    _ZL3fooPKcj.avx512f(%rip), %rax
.L7:
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc
        .section        .text.unlikely
        .cfi_startproc
        .type   _ZL3fooPKcj.resolver.cold, @function
_ZL3fooPKcj.resolver.cold:
.LFSB6:
.L8:
        .cfi_def_cfa_offset 16
        testb   $2, %ah
        leaq    _ZL3fooPKcj.avx(%rip), %rdx
        leaq    _ZL3fooPKcj(%rip), %rax
        cmovne  %rdx, %rax
        jmp     .L7
        .cfi_endproc
.LFE6:
        .text
        .size   _ZL3fooPKcj.resolver, .-_ZL3fooPKcj.resolver
        .section        .text.unlikely
        .size   _ZL3fooPKcj.resolver.cold, .-_ZL3fooPKcj.resolver.cold
.LCOLDE0:
        .text
.LHOTE0:
        .type   _Z11_ZL3fooPKcjPKcj, @gnu_indirect_function
        .set    _Z11_ZL3fooPKcjPKcj,_ZL3fooPKcj.resolver
        .p2align 4
        .globl  _Z3barv
        .type   _Z3barv, @function
_Z3barv:
.LFB3:
        .cfi_startproc
        pushq   %r12
        .cfi_def_cfa_offset 16
        .cfi_offset 12, -16
        xorl    %r12d, %r12d
        pushq   %rbp
        .cfi_def_cfa_offset 24
        .cfi_offset 6, -24
        pushq   %rbx
        .cfi_def_cfa_offset 32
        .cfi_offset 3, -32
        subq    $4112, %rsp
        .cfi_def_cfa_offset 4144
        movq    %fs:40, %rax
        movq    %rax, 4104(%rsp)
        xorl    %eax, %eax
        movq    %rsp, %rbx
        leaq    4096(%rsp), %rbp
        .p2align 4,,10
        .p2align 3
.L12:
        movq    %rbx, %rdi
        movl    $1, %esi
        addq    $1, %rbx
        call    _Z11_ZL3fooPKcjPKcj@PLT
        addl    %eax, %r12d
        cmpq    %rbp, %rbx
        jne     .L12
        movq    4104(%rsp), %rax
        subq    %fs:40, %rax
        jne     .L16
        addq    $4112, %rsp
        .cfi_remember_state
        .cfi_def_cfa_offset 32
        movl    %r12d, %eax
        popq    %rbx
        .cfi_def_cfa_offset 24
        popq    %rbp
        .cfi_def_cfa_offset 16
        popq    %r12
        .cfi_def_cfa_offset 8
        ret
.L16:
        .cfi_restore_state
        call    __stack_chk_fail@PLT
        .cfi_endproc
.LFE3:
        .size   _Z3barv, .-_Z3barv
        .p2align 4
        .globl  _Z3barv.avx
        .type   _Z3barv.avx, @function
_Z3barv.avx:
.LFB4:
        .cfi_startproc
        pushq   %r12
        .cfi_def_cfa_offset 16
        .cfi_offset 12, -16
        xorl    %r12d, %r12d
        pushq   %rbp
        .cfi_def_cfa_offset 24
        .cfi_offset 6, -24
        pushq   %rbx
        .cfi_def_cfa_offset 32
        .cfi_offset 3, -32
        subq    $4112, %rsp
        .cfi_def_cfa_offset 4144
        movq    %fs:40, %rax
        movq    %rax, 4104(%rsp)
        xorl    %eax, %eax
        movq    %rsp, %rbx
        leaq    4096(%rsp), %rbp
        .p2align 4,,10
        .p2align 3
.L18:
        movq    %rbx, %rdi
        movl    $1, %esi
        addq    $1, %rbx
        call    _Z11_ZL3fooPKcjPKcj@PLT
        addl    %eax, %r12d
        cmpq    %rbp, %rbx
        jne     .L18
        movq    4104(%rsp), %rax
        subq    %fs:40, %rax
        jne     .L22
        addq    $4112, %rsp
        .cfi_remember_state
        .cfi_def_cfa_offset 32
        movl    %r12d, %eax
        popq    %rbx
        .cfi_def_cfa_offset 24
        popq    %rbp
        .cfi_def_cfa_offset 16
        popq    %r12
        .cfi_def_cfa_offset 8
        ret
.L22:
        .cfi_restore_state
        call    __stack_chk_fail@PLT
        .cfi_endproc
.LFE4:
        .size   _Z3barv.avx, .-_Z3barv.avx
        .ident  "GCC: (GNU) 10.1.0"
        .section        .note.GNU-stack,"",@progbits


More information about the Gcc-bugs mailing list