public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dl.soluz at gmx dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/58483] missing optimization opportunity for const std::vector compared to std::array
Date: Sun, 14 Nov 2021 14:19:57 +0000	[thread overview]
Message-ID: <bug-58483-4-lArO1wUX12@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58483-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #16 from dennis luehring <dl.soluz at gmx dot net> ---
the sample still gets reduced by clang to 160 with -O2 or -O3

clang:

main:                                   # @main
        mov     eax, 160
        ret

and gcc 11.2/trunk producing

-O2
main:
        push    rbp
        mov     edi, 12
        sub     rsp, 48
        movq    xmm15, QWORD PTR .LC0[rip]
        mov     DWORD PTR [rsp+8], 30
        movq    QWORD PTR [rsp], xmm15
        pxor    xmm15, xmm15
        mov     QWORD PTR [rsp+32], 0
        movaps  XMMWORD PTR [rsp+16], xmm15
        call    operator new(unsigned long)
        mov     rcx, QWORD PTR [rsp]
        lea     rdx, [rax+12]
        lea     rdi, [rsp+16]
        mov     QWORD PTR [rsp+16], rax
        mov     QWORD PTR [rsp+32], rdx
        mov     QWORD PTR [rax], rcx
        mov     ecx, DWORD PTR [rsp+8]
        mov     QWORD PTR [rsp+24], rdx
        mov     DWORD PTR [rax+8], ecx
        call    std::_Vector_base<int, std::allocator<int> >::~_Vector_base()
[base object destructor]
        add     rsp, 48
        mov     eax, 160
        pop     rbp
        ret
        mov     rbp, rax
        jmp     .L5
main.cold:
.LC0:
        .long   10
        .long   20

-O3
main:
        sub     rsp, 24
        mov     edi, 12
        movq    xmm15, QWORD PTR .LC0[rip]
        mov     DWORD PTR [rsp+8], 30
        movq    QWORD PTR [rsp], xmm15
        call    operator new(unsigned long)
        mov     esi, 12
        mov     rdi, rax
        mov     rax, QWORD PTR [rsp]
        mov     QWORD PTR [rdi], rax
        mov     eax, DWORD PTR [rsp+8]
        mov     DWORD PTR [rdi+8], eax
        call    operator delete(void*, unsigned long)
        mov     eax, 160
        add     rsp, 24
        ret
.LC0:
        .long   10
        .long   20


does that mean its still not clear if the unused new/delete can be removed
here?

  parent reply	other threads:[~2021-11-14 14:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20 11:03 [Bug tree-optimization/58483] New: " dl.soluz at gmx dot net
2013-09-20 11:14 ` [Bug tree-optimization/58483] " glisse at gcc dot gnu.org
2013-09-20 11:17 ` dl.soluz at gmx dot net
2013-09-20 14:46 ` dl.soluz at gmx dot net
2013-09-28 18:52 ` dl.soluz at gmx dot net
2013-09-29  8:06 ` dl.soluz at gmx dot net
2013-10-03 23:57 ` glisse at gcc dot gnu.org
2013-10-08 10:43 ` glisse at gcc dot gnu.org
2014-05-28 12:24 ` glisse at gcc dot gnu.org
2014-06-04  5:48 ` dl.soluz at gmx dot net
2014-06-04  6:21 ` glisse at gcc dot gnu.org
2021-11-14 14:19 ` dl.soluz at gmx dot net [this message]
2023-05-30 18:43 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58483-4-lArO1wUX12@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).