public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/62128] New: Use vpalignr for AVX2 rotation
@ 2014-08-13 20:21 glisse at gcc dot gnu.org
  2014-08-14  8:16 ` [Bug target/62128] " evstupac at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2014-08-13 20:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 62128
           Summary: Use vpalignr for AVX2 rotation
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org
            Target: x86_64-linux-gnu

typedef unsigned char vec __attribute__((vector_size(32)));
vec f(vec x){
  vec
m={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,0};
  return __builtin_shuffle(x,m);
}

We generate, with -O3 -mavx2:

    vpshufb    .LC0(%rip), %ymm0, %ymm1
    vpshufb    .LC1(%rip), %ymm0, %ymm0
    vpermq    $78, %ymm1, %ymm1
    vpor    %ymm1, %ymm0, %ymm0

But unless I am mistaken, a lane swap and vpalignr should do it in 2
instructions and without reading constants from memory. There is a function
expand_vec_perm_palignr but it only handles some 128 bit cases. Even for
permutations that can be done with a single 256 bit vpalignr instruction, we
never seem to generate it.


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

* [Bug target/62128] Use vpalignr for AVX2 rotation
  2014-08-13 20:21 [Bug target/62128] New: Use vpalignr for AVX2 rotation glisse at gcc dot gnu.org
@ 2014-08-14  8:16 ` evstupac at gmail dot com
  2014-08-26 13:50 ` evstupac at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: evstupac at gmail dot com @ 2014-08-14  8:16 UTC (permalink / raw)
  To: gcc-bugs

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

Stupachenko Evgeny <evstupac at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |evstupac at gmail dot com

--- Comment #1 from Stupachenko Evgeny <evstupac at gmail dot com> ---
Confirm.
A part of the patch fixing this discussed at:
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg01434.html
The other part is generation of corresponding pattern for rotation. I'll create
corresponding patch.


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

* [Bug target/62128] Use vpalignr for AVX2 rotation
  2014-08-13 20:21 [Bug target/62128] New: Use vpalignr for AVX2 rotation glisse at gcc dot gnu.org
  2014-08-14  8:16 ` [Bug target/62128] " evstupac at gmail dot com
@ 2014-08-26 13:50 ` evstupac at gmail dot com
  2014-10-02  7:30 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: evstupac at gmail dot com @ 2014-08-26 13:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Stupachenko Evgeny <evstupac at gmail dot com> ---
The patch fixing this submitted for review.
Code generated when patch applied:

        vperm2i128      $33, %ymm0, %ymm0, %ymm1
        vpalignr        $1, %ymm0, %ymm1, %ymm1
        vmovdqa %ymm1, %ymm0


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

* [Bug target/62128] Use vpalignr for AVX2 rotation
  2014-08-13 20:21 [Bug target/62128] New: Use vpalignr for AVX2 rotation glisse at gcc dot gnu.org
  2014-08-14  8:16 ` [Bug target/62128] " evstupac at gmail dot com
  2014-08-26 13:50 ` evstupac at gmail dot com
@ 2014-10-02  7:30 ` jakub at gcc dot gnu.org
  2014-10-03  7:28 ` jakub at gcc dot gnu.org
  2014-11-28  9:08 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-02  7:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Thu Oct  2 07:29:49 2014
New Revision: 215796

URL: https://gcc.gnu.org/viewcvs?rev=215796&root=gcc&view=rev
Log:
    PR target/62128
    * config/i386/i386.c (expand_vec_perm_1): Try expand_vec_perm_palignr
    if it expands to a single insn only.
    (expand_vec_perm_palignr): Add SINGLE_INSN_ONLY_P argument.  If true,
    fail unless in_order is true.  Add forward declaration.
    (expand_vec_perm_vperm2f128): Fix up comment about which permutation
    is useful for one_operand_p.
    (ix86_expand_vec_perm_const_1): Adjust expand_vec_perm_palignr caller.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c


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

* [Bug target/62128] Use vpalignr for AVX2 rotation
  2014-08-13 20:21 [Bug target/62128] New: Use vpalignr for AVX2 rotation glisse at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-10-02  7:30 ` jakub at gcc dot gnu.org
@ 2014-10-03  7:28 ` jakub at gcc dot gnu.org
  2014-11-28  9:08 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-03  7:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Oct  3 07:27:50 2014
New Revision: 215834

URL: https://gcc.gnu.org/viewcvs?rev=215834&root=gcc&view=rev
Log:
    PR target/62128
    * config/i386/i386.c (expand_vec_perm_palignr): If op1, op0 order
    of palignr arguments can't be used due to min 0 or max - min
    too high, try also op0, op1 order of palignr arguments.

    * gcc.dg/torture/vshuf-16.inc (TESTS): Add 2 new permutations.
    * gcc.dg/torture/vshuf-32.inc (TESTS): Add 5 new permutations.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/torture/vshuf-16.inc
    trunk/gcc/testsuite/gcc.dg/torture/vshuf-32.inc


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

* [Bug target/62128] Use vpalignr for AVX2 rotation
  2014-08-13 20:21 [Bug target/62128] New: Use vpalignr for AVX2 rotation glisse at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2014-10-03  7:28 ` jakub at gcc dot gnu.org
@ 2014-11-28  9:08 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-28  9:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jakub at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be fixed now.


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

end of thread, other threads:[~2014-11-28  9:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-13 20:21 [Bug target/62128] New: Use vpalignr for AVX2 rotation glisse at gcc dot gnu.org
2014-08-14  8:16 ` [Bug target/62128] " evstupac at gmail dot com
2014-08-26 13:50 ` evstupac at gmail dot com
2014-10-02  7:30 ` jakub at gcc dot gnu.org
2014-10-03  7:28 ` jakub at gcc dot gnu.org
2014-11-28  9:08 ` jakub 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).