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 middle-end/65962] Missed vectorization of strided stores
Date: Thu, 22 Oct 2015 10:28:00 -0000	[thread overview]
Message-ID: <bug-65962-4-f0kJ9Unz0Z@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65962-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
While strided stores are now implemented the case is still not handled because
single-element interleaving takes precedence (and single-element interleaving
isn't supported for stores as that always produces gaps).

I have a patch that produces

.L2:
        movdqu  16(%rax), %xmm1
        addq    $32, %rax
        movdqu  -32(%rax), %xmm0
        shufps  $136, %xmm1, %xmm0
        paddd   %xmm2, %xmm0
        pshufd  $85, %xmm0, %xmm1
        movd    %xmm0, -32(%rax)
        movd    %xmm1, -24(%rax)
        movdqa  %xmm0, %xmm1
        punpckhdq       %xmm0, %xmm1
        pshufd  $255, %xmm0, %xmm0
        movd    %xmm1, -16(%rax)
        movd    %xmm0, -8(%rax)
        cmpq    %rdx, %rax
        jne     .L2

when you disable the cost model.  Otherwise it's deemed not profitable.  Using
scatters for AVX could in theory make it profitable (not sure).

t.c:5:3: note: Cost model analysis:
  Vector inside of loop cost: 13
  Vector prologue cost: 1
  Vector epilogue cost: 12
  Scalar iteration cost: 3
  Scalar outside cost: 0
  Vector outside cost: 13
  prologue iterations: 0
  epilogue iterations: 4
t.c:5:3: note: cost model: the vector iteration cost = 13 divided by the scalar
iteration cost = 3 is greater or equal to the vectorization factor = 4.
t.c:5:3: note: not vectorized: vectorization not profitable.
t.c:5:3: note: not vectorized: vector version will never be profitable.

t.c:5:3: note: ==> examining statement: *_8 = _10;
t.c:5:3: note: vect_is_simple_use: operand _10
t.c:5:3: note: def_stmt: _10 = _9 + 7;
t.c:5:3: note: type of def: internal
t.c:5:3: note: vect_model_store_cost: inside_cost = 8, prologue_cost = 0 .

so the strided store has cost 8, that's 4 extracts plus 4 scalar stores.
With AVX we generate

        vmovd   %xmm0, -32(%rax)
        vpextrd $1, %xmm0, -24(%rax)
        vpextrd $2, %xmm0, -16(%rax)
        vpextrd $3, %xmm0, -8(%rax)

so it can combine extract and store, with SSE2 we get

        pshufd  $85, %xmm0, %xmm1
        movd    %xmm0, -32(%rax)
        movd    %xmm1, -24(%rax)
        movdqa  %xmm0, %xmm1
        punpckhdq       %xmm0, %xmm1
        pshufd  $255, %xmm0, %xmm0
        movd    %xmm1, -16(%rax)
        movd    %xmm0, -8(%rax)

which is even worse than expected ;)

As usual the cost model isn't target aware enough here (and it errs on the
conservative side here)


  parent reply	other threads:[~2015-10-22 10:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-01 11:45 [Bug middle-end/65962] New: " alalaw01 at gcc dot gnu.org
2015-05-01 11:46 ` [Bug middle-end/65962] " alalaw01 at gcc dot gnu.org
2015-05-04 11:19 ` rguenth at gcc dot gnu.org
2015-10-22 10:28 ` rguenth at gcc dot gnu.org [this message]
2015-10-22 13:33 ` rguenth at gcc dot gnu.org
2015-10-22 13:34 ` rguenth at gcc dot gnu.org
2015-10-23 22:32 ` wschmidt at gcc dot gnu.org
2015-10-26 11:51 ` rguenth at gcc dot gnu.org
2015-10-26 16:51 ` wschmidt at gcc dot gnu.org
2015-10-26 16:52 ` wschmidt at gcc dot gnu.org
2015-10-26 16:52 ` wschmidt at gcc dot gnu.org
2015-10-27 11:16 ` rguenth at gcc dot gnu.org
2015-10-27 13:17 ` wschmidt at gcc dot gnu.org
2015-10-28 10:10 ` rguenth at gcc dot gnu.org
2015-10-28 16:47 ` clyon at gcc dot gnu.org
2015-10-29  9:48 ` rguenther at suse dot de
2015-10-29 14:57 ` clyon at gcc dot gnu.org
2015-10-29 14:58 ` clyon at gcc dot gnu.org
2015-10-29 14:59 ` clyon at gcc dot gnu.org
2015-10-29 15:14 ` rguenth at gcc dot gnu.org
2015-10-30  9:49 ` clyon 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-65962-4-f0kJ9Unz0Z@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: link
Be 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).