[llvm-bugs] [Bug 52269] New: Passing small struct by value - suboptimal codegen

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 23 07:23:44 PDT 2021


            Bug ID: 52269
           Summary: Passing small struct by value - suboptimal codegen
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

struct X
  char mem0[32];
  char mem1[32];

void bar (struct X);

foo1(struct X *x)

LLVM -O3 or even -Oz:
foo1:                                   # @foo1
        sub     rsp, 136
        movups  xmm0, xmmword ptr [rdi]
        movups  xmm1, xmmword ptr [rdi + 16]
        movups  xmm2, xmmword ptr [rdi + 32]
        movups  xmm3, xmmword ptr [rdi + 48]
        movaps  xmmword ptr [rsp + 112], xmm3
        movaps  xmmword ptr [rsp + 96], xmm2
        movaps  xmmword ptr [rsp + 80], xmm1
        movaps  xmmword ptr [rsp + 64], xmm0
        movaps  xmm0, xmmword ptr [rsp + 64]
        movaps  xmm1, xmmword ptr [rsp + 80]
        movaps  xmm2, xmmword ptr [rsp + 96]
        movaps  xmm3, xmmword ptr [rsp + 112]
        movups  xmmword ptr [rsp + 48], xmm3
        movups  xmmword ptr [rsp + 32], xmm2
        movups  xmmword ptr [rsp + 16], xmm1
        movups  xmmword ptr [rsp], xmm0
        call    bar
        add     rsp, 136

        sub     rsp, 72
        movdqu  xmm0, XMMWORD PTR [rdi]
        movdqu  xmm1, XMMWORD PTR [rdi+16]
        movdqu  xmm2, XMMWORD PTR [rdi+32]
        movdqu  xmm3, XMMWORD PTR [rdi+48]
        movups  XMMWORD PTR [rsp], xmm0
        movups  XMMWORD PTR [rsp+16], xmm1
        movups  XMMWORD PTR [rsp+32], xmm2
        movups  XMMWORD PTR [rsp+48], xmm3
        call    bar
        add     rsp, 72

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211023/2f1c3b2d/attachment.html>

More information about the llvm-bugs mailing list