https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95779
Bug ID: 95779 Summary: Unnecessary dispatch function for static target_clones function. Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: yyc1992 at gmail dot com Target Milestone: --- Using the code in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95778 the full assembly generated (the version with both noinline) is (disabled unwind info), ``` .file "b.c" .text .p2align 4 .type f2.default.1, @function f2.default.1: movl (%rdi), %eax ret .size f2.default.1, .-f2.default.1 .p2align 4 .type g2.default.1, @function g2.default.1: jmp f2.default.1 .size g2.default.1, .-g2.default.1 .p2align 4 .type f2.avx2.0, @function f2.avx2.0: movl (%rdi), %eax ret .size f2.avx2.0, .-f2.avx2.0 .p2align 4 .type g2.avx2.0, @function g2.avx2.0: jmp f2.avx2.0 .size g2.avx2.0, .-g2.avx2.0 .section .text.g2.resolver,"axG",@progbits,g2.resolver,comdat .p2align 4 .weak g2.resolver .type g2.resolver, @function g2.resolver: subq $8, %rsp call __cpu_indicator_init@PLT movq __cpu_model@GOTPCREL(%rip), %rax leaq g2.avx2.0(%rip), %rdx testb $4, 13(%rax) leaq g2.default.1(%rip), %rax cmovne %rdx, %rax addq $8, %rsp ret .size g2.resolver, .-g2.resolver .globl g2 .type g2, @gnu_indirect_function .set g2,g2.resolver .text .p2align 4 .type f2.resolver, @function f2.resolver: subq $8, %rsp call __cpu_indicator_init@PLT movq __cpu_model@GOTPCREL(%rip), %rax leaq f2.avx2.0(%rip), %rdx testb $4, 13(%rax) leaq f2.default.1(%rip), %rax cmovne %rdx, %rax addq $8, %rsp ret .size f2.resolver, .-f2.resolver .ident "GCC: (GNU) 10.1.0" .section .note.GNU-stack,"",@progbits ``` AFAICT the `f2.resolver` is never used anywhere and can be omitted (all caller of `f2` are statically dispatched).