public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/65832] Inefficient vector construction Date: Tue, 28 Apr 2015 08:51:00 -0000 [thread overview] Message-ID: <bug-65832-4-lXhTjiZpob@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-65832-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65832 --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Another example where the vectorizer thinks vectorization is profitable: #define N 16 unsigned int out[N]; unsigned int in[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; __attribute__ ((noinline)) int main1 (unsigned int x, unsigned int y) { int i; unsigned int a0, a1, a2, a3; a0 = in[0]; a1 = in[1]; a2 = in[2]; a3 = in[3]; out[0] = a0 * x; out[1] = a1 * y; out[2] = a2 * x; out[3] = a3 * y; } generates main1: .LFB0: .cfi_startproc movl %edi, -12(%rsp) movd -12(%rsp), %xmm0 movl %esi, -12(%rsp) movd -12(%rsp), %xmm3 movdqa in(%rip), %xmm2 punpckldq %xmm3, %xmm0 psrlq $32, %xmm2 punpcklqdq %xmm0, %xmm0 movdqa %xmm0, %xmm1 psrlq $32, %xmm0 pmuludq %xmm2, %xmm0 pshufd $8, %xmm0, %xmm0 pmuludq in(%rip), %xmm1 pshufd $8, %xmm1, %xmm1 punpckldq %xmm0, %xmm1 movaps %xmm1, out(%rip) ret slightly less obfuscated when we allow gpr xmm moves with -mtune=intel: main1: .LFB0: .cfi_startproc movd %edi, %xmm0 movd %esi, %xmm3 movdqa in(%rip), %xmm2 punpckldq %xmm3, %xmm0 punpcklqdq %xmm0, %xmm0 psrlq $32, %xmm2 movdqa %xmm0, %xmm1 psrlq $32, %xmm0 pmuludq in(%rip), %xmm1 pmuludq %xmm2, %xmm0 pshufd $8, %xmm1, %xmm1 pshufd $8, %xmm0, %xmm0 punpckldq %xmm0, %xmm1 movdqa %xmm1, out(%rip) ret so for { x, y, x, y } construction we generate movd %edi, %xmm0 movd %esi, %xmm3 punpckldq %xmm3, %xmm0 punpcklqdq %xmm0, %xmm0 no f*** idea where all the shifting and shuffling comes from... This is just vect_cst_.7_18 = {x_6(D), y_9(D), x_6(D), y_9(D)}; vect_a0_2.5_17 = MEM[(unsigned int *)&in]; vect__7.6_19 = vect_a0_2.5_17 * vect_cst_.7_18; MEM[(unsigned int *)&out] = vect__7.6_19;
next prev parent reply other threads:[~2015-04-28 8:51 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-04-21 13:56 [Bug target/65832] New: " rguenth at gcc dot gnu.org 2015-04-21 14:03 ` [Bug target/65832] " rguenth at gcc dot gnu.org 2015-04-21 14:11 ` rguenth at gcc dot gnu.org 2015-04-28 8:51 ` rguenth at gcc dot gnu.org [this message] 2015-04-28 8:55 ` rguenth at gcc dot gnu.org 2015-05-22 12:15 ` rguenth at gcc dot gnu.org 2015-06-01 10:30 ` rguenth at gcc dot gnu.org 2020-06-24 20:45 ` [Bug middle-end/65832] " gabravier at gmail 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-65832-4-lXhTjiZpob@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).