[libcxx-commits] [PATCH] D68623: Optimize and Fix move assignment operator

Martijn Vels via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 7 19:42:32 PDT 2019


mvels added a comment.

Here's the godbolt link I am looking at with your code:

https://gcc.godbolt.org/z/6xBGhB

  main:                                   # @main
          push    rax
          mov     rcx, qword ptr [rip + dest[abi:cxx11]]
          mov     eax, offset dest[abi:cxx11]+16
          cmp     rcx, rax
          je      .LBB0_1
          mov     rax, qword ptr [rip + source[abi:cxx11]]
          mov     edx, offset source[abi:cxx11]+16
          cmp     rax, rdx
          je      .LBB0_7
          mov     rdx, qword ptr [rip + source[abi:cxx11]+16]
          mov     qword ptr [rip + source[abi:cxx11]], rcx
          movups  xmm0, xmmword ptr [rip + dest[abi:cxx11]+8]
          movups  xmmword ptr [rip + source[abi:cxx11]+8], xmm0
          test    rax, rax
          je      .LBB0_8
          mov     qword ptr [rip + dest[abi:cxx11]], rax
          mov     qword ptr [rip + dest[abi:cxx11]+16], rdx
          jmp     .LBB0_11
  .LBB0_1:
          mov     rdx, qword ptr [rip + dest[abi:cxx11]+8]
          test    rdx, rdx
          je      .LBB0_5
          mov     rdi, qword ptr [rip + source[abi:cxx11]]
          cmp     rdx, 1
          jne     .LBB0_4
          mov     al, byte ptr [rip + dest[abi:cxx11]+16]
          mov     byte ptr [rdi], al
          jmp     .LBB0_5
  .LBB0_7:
          mov     qword ptr [rip + source[abi:cxx11]], rcx
          movups  xmm0, xmmword ptr [rip + dest[abi:cxx11]+8]
          movups  xmmword ptr [rip + source[abi:cxx11]+8], xmm0
  .LBB0_8:
          mov     qword ptr [rip + dest[abi:cxx11]], offset dest[abi:cxx11]+16
          mov     eax, offset dest[abi:cxx11]+16
          jmp     .LBB0_11
  .LBB0_4:
          mov     esi, offset dest[abi:cxx11]+16
          call    memcpy
  .LBB0_5:
          mov     rax, qword ptr [rip + dest[abi:cxx11]+8]
          mov     qword ptr [rip + source[abi:cxx11]+8], rax
          mov     rcx, qword ptr [rip + source[abi:cxx11]]
          mov     byte ptr [rcx + rax], 0
          mov     rax, qword ptr [rip + dest[abi:cxx11]]
  .LBB0_11:
          mov     qword ptr [rip + dest[abi:cxx11]+8], 0
          mov     byte ptr [rax], 0
          mov     eax, dword ptr [rip + dest[abi:cxx11]+8]
          pop     rcx
          ret

In my local godbolt with the change (I may spin up a cloud instance if I have some time), the codegen is:

  main:                                   # @main
          push    rax
          cmp     byte ptr [rip + source+23], 0
          jns     .LBB0_2
          mov     rdi, qword ptr [rip + source]
          call    operator delete(void*)
  .LBB0_2:
          mov     rax, qword ptr [rip + dest+16]
          mov     qword ptr [rip + source+16], rax
          movups  xmm0, xmmword ptr [rip + dest]
          movups  xmmword ptr [rip + source], xmm0
          mov     byte ptr [rip + dest+23], 0
          mov     byte ptr [rip + dest], 0
          xor     eax, eax
          pop     rcx
          ret


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68623/new/

https://reviews.llvm.org/D68623





More information about the libcxx-commits mailing list