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

            Bug ID: 118465
           Summary: un-needed aligning the stack in some cases
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: x86_64

Created attachment 60144
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60144&action=edit
testcase

At -O3, look at _TAIL_CALL_YIELD_VALUE, there is:

GCC produces:
        pushq   %rbx
        movq    -24(%rdi), %rax
        addq    $2, %rcx
        subl    $2, %r9d
        movq    -8(%rsi), %r8
        subq    $8, %rsi
        movb    %r9b, -5(%rdi)
        movq    %rcx, 56(%rdi)
        movq    %rsi, 64(%rdi)
        movq    %rax, 120(%rdx)
        movq    8(%rdi), %rax
        movq    $0, -24(%rdi)
        movq    56(%rax), %rcx
        movq    64(%rax), %rsi
        movq    %rax, 72(%rdx)
        addl    $1, 44(%rdx)
        movzwl  4(%rcx), %r9d
        movq    $0, 8(%rdi)
        addq    $4, %rcx
        addq    $8, %rsi
        movq    $0, 64(%rax)
        movl    %r9d, %ebx
        movzbl  %r9b, %edi
        movq    %r8, -8(%rsi)
        movzbl  %bh, %ebx
        movq    INSTRUCTION_TABLE(,%rdi,8), %r10
        movq    %rdi, %r8
        movq    %rax, %rdi
        movl    %ebx, %r9d
        popq    %rbx
        jmp     *%r10

But rbx is not used nor is the stack. I have attached the original preprocessed
source but I have not extracted a simplified version yet. The push/pop as far
as I can tell is only to align the stack to 16 bytes but it seems not to be
needed as there is no stack usage nor uses of rbx.

Originally reported at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118328#c7
but that is about preserve_none for aarch64 while the issue being reported in
the comment section is about x86_64.

Reply via email to