public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "lh_mouse at 126 dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104588] New: user-defined constructor loses alignment information about `*this` Date: Fri, 18 Feb 2022 05:24:30 +0000 [thread overview] Message-ID: <bug-104588-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104588 Bug ID: 104588 Summary: user-defined constructor loses alignment information about `*this` Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lh_mouse at 126 dot com Target Milestone: --- Target: x86_64-linux-gnu https://gcc.godbolt.org/z/M3YoaYeEf ```c++ struct alignas(16) foo { unsigned char a[32]; foo() : a() { } };t struct alignas(16) bar { foo f; long m,n,p,q; bar() : f(),m(),n(),p(),q() { } }; constexpr void* operator new(unsigned long, void* p) noexcept { return p; } inline void operator delete(void*, void*) noexcept { } bar* construct(bar* p) { return new(p) bar(); } ``` For `bar::bar()` with -O3, GCC generates two `MOVUPS` followed by two `MOVAPS`, while Clang generates four `MOVAPS`. `MOVUPS` was slow on some older CPUs. GCC output: ``` construct(bar*): pxor xmm0, xmm0 mov rax, rdi movups XMMWORD PTR [rdi], xmm0 movups XMMWORD PTR [rdi+16], xmm0 pxor xmm0, xmm0 movaps XMMWORD PTR [rdi+32], xmm0 movaps XMMWORD PTR [rdi+48], xmm0 ret ``` Clang output: ``` construct(bar*): # @construct(bar*) mov rax, rdi xorps xmm0, xmm0 movaps xmmword ptr [rdi + 48], xmm0 movaps xmmword ptr [rdi + 32], xmm0 movaps xmmword ptr [rdi + 16], xmm0 movaps xmmword ptr [rdi], xmm0 ret ```
next reply other threads:[~2022-02-18 5:24 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-18 5:24 lh_mouse at 126 dot com [this message] 2022-02-18 5:38 ` [Bug middle-end/104588] memset loses alignment infomation in some cases pinskia at gcc dot gnu.org 2022-02-18 7:36 ` [Bug c++/104588] " rguenth at gcc dot gnu.org 2022-02-18 12:26 ` lh_mouse at 126 dot com
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-104588-4@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: linkBe 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).