public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pskocik at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/94703] Small-sized memcpy leading to unnecessary register spillage unless done through a dummy union Date: Wed, 13 May 2020 16:00:43 +0000 [thread overview] Message-ID: <bug-94703-4-PWbTPZZ9Av@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94703-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94703 --- Comment #11 from pskocik at gmail dot com --- Thanks for the shot at a fix, Richard Biener. Since I have reported this, I think I should mentioned a related suboptimality that should probably be getting fixed alongside with this (if this one is getting fixed), namely that while int64_t zextend_int_to_int64_nospill(int *X) { union { int64_t _; } r = {0}; return memcpy(&r._,X,sizeof(*X)),r._; } (and hopefully later even int64_t zextend_int_to_int64_spill(int *X) { int64_t r = {0}; return memcpy(&r,X,sizeof(*X)),r; } ) generates, on x86_64, the optimal zextend_int_to_int64_nospill: mov eax, DWORD PTR [rdi] ret for zeroextending promotions of sub-int types, an extra xor instruction gets generated, e.g.: int64_t zextend_short_to_int64_nospill_but_suboptimal(short *X) { union { int64_t _; } r ={0}; return memcpy(&r._,X,sizeof(*X)),r._; } => zextend_short_to_int64_nospill_but_suboptimal: xor eax, eax mov ax, WORD PTR [rdi] ret which was surprising to me because it doesn't happen with zero-extending memcpy-based promotion from {,u}ints to larger types ({,u}{,l}longs). https://gcc.godbolt.org/z/ZjXaCw
next prev parent reply other threads:[~2020-05-13 16:00 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-21 21:07 [Bug c/94703] New: " pskocik at gmail dot com 2020-04-22 7:28 ` [Bug middle-end/94703] " rguenth at gcc dot gnu.org 2020-04-22 7:34 ` rguenth at gcc dot gnu.org 2020-04-22 7:59 ` rguenth at gcc dot gnu.org 2020-04-22 8:46 ` rguenth at gcc dot gnu.org 2020-05-07 13:39 ` cvs-commit at gcc dot gnu.org 2020-05-07 13:41 ` rguenth at gcc dot gnu.org 2020-05-08 11:03 ` ro at gcc dot gnu.org 2020-05-08 11:03 ` ro at gcc dot gnu.org 2020-05-08 11:19 ` rguenth at gcc dot gnu.org 2020-05-13 14:43 ` ro at CeBiTec dot Uni-Bielefeld.DE 2020-05-13 16:00 ` pskocik at gmail dot com [this message] 2020-05-14 9:10 ` rguenth at gcc dot gnu.org 2020-05-14 9:49 ` rguenth at gcc dot gnu.org 2020-05-14 9:54 ` cvs-commit at gcc dot gnu.org 2020-05-14 9:55 ` rguenth 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-94703-4-PWbTPZZ9Av@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).