public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110819] New: Missed optimization: when vector size is 0 but vector::reserve has been called.
@ 2023-07-26 16:37 hiraditya at msn dot com
  2023-07-26 16:38 ` [Bug tree-optimization/110819] Missed optimization: when vector's " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: hiraditya at msn dot com @ 2023-07-26 16:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110819
           Summary: Missed optimization: when vector size is 0 but
                    vector::reserve has been called.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hiraditya at msn dot com
  Target Milestone: ---

#include<vector>

void f(int);

void use_idx_const_size_reserve() {
    std::vector<int> v;
    v.reserve(100000);
    auto s = v.size();
    for (std::vector<int>::size_type i = 0; i < s; i++)
        f(v[i]);
}

$ g++ -O3

use_idx_const_size_reserve():
        sub     rsp, 8
        mov     edi, 400000
        call    operator new(unsigned long)
        mov     esi, 400000
        add     rsp, 8
        mov     rdi, rax
        jmp     operator delete(void*, unsigned long)


$ clang++ -O3 -stdlib=libc++

use_idx_const_size_reserve():        # @use_idx_const_size_reserve()
        ret

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-29  7:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26 16:37 [Bug c++/110819] New: Missed optimization: when vector size is 0 but vector::reserve has been called hiraditya at msn dot com
2023-07-26 16:38 ` [Bug tree-optimization/110819] Missed optimization: when vector's " pinskia at gcc dot gnu.org
2023-07-26 18:02 ` redi at gcc dot gnu.org
2023-07-29  2:08 ` hiraditya at msn dot com
2023-07-29  7:15 ` xry111 at gcc dot gnu.org

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).