public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111805] New: suboptimal codegen of variant<string, bool>
@ 2023-10-14  5:40 hiraditya at msn dot com
  2023-10-14 15:29 ` [Bug c++/111805] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hiraditya at msn dot com @ 2023-10-14  5:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111805
           Summary: suboptimal codegen of variant<string, bool>
           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<variant>
#include<string>

std::string foo() {
    std::variant<std::string, bool> v {"abc"};
    return std::get<0>(v);
}

g++-13.2 -O2 -std=c++20


foo[abi:cxx11]():
        lea     rdx, [rdi+16]
        mov     BYTE PTR [rdi+18], 99
        mov     rax, rdi
        mov     QWORD PTR [rdi], rdx
        mov     edx, 25185
        mov     WORD PTR [rdi+16], dx
        mov     QWORD PTR [rdi+8], 3
        mov     BYTE PTR [rdi+19], 0
        ret


clang++ -O2 -std=c++20

foo():                                # @foo()
        mov     rax, rdi
        mov     byte ptr [rdi], 6
        mov     dword ptr [rdi + 1], 6513249
        ret


https://godbolt.org/z/nTv5rYanM

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

end of thread, other threads:[~2023-10-16  6:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-14  5:40 [Bug c++/111805] New: suboptimal codegen of variant<string, bool> hiraditya at msn dot com
2023-10-14 15:29 ` [Bug c++/111805] " pinskia at gcc dot gnu.org
2023-10-14 15:36 ` [Bug middle-end/111805] " pinskia at gcc dot gnu.org
2023-10-16  6:48 ` rguenth 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).