public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52577] New: __builtin_shuffle -Wunused-but-set-* false positives
@ 2012-03-13  8:33 jakub at gcc dot gnu.org
  2012-03-13  8:36 ` [Bug c/52577] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-13  8:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52577

             Bug #: 52577
           Summary: __builtin_shuffle -Wunused-but-set-* false positives
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jakub@gcc.gnu.org
                CC: marc.glisse@normalesup.org
        Depends on: 52568


+++ This bug was initially created as a clone of Bug #52568 +++

Hello,
I compiled the following with -O3 (or -Os) and -mavx

#include <x86intrin.h>
__m256d left(__m256d x){
  __m256i mask={1,2,3,0};
  return __builtin_shuffle(x,mask);
}

(by the way, for some reason, gcc insists that 'mask' is set but not used with
-Wall)

and got:
    vunpckhpd    %xmm0, %xmm0, %xmm3
    vmovapd    %xmm0, %xmm1
    vextractf128    $0x1, %ymm0, %xmm0
    vmovaps    %xmm0, %xmm2
    vunpckhpd    %xmm0, %xmm0, %xmm0
    vunpcklpd    %xmm1, %xmm0, %xmm1
    vunpcklpd    %xmm2, %xmm3, %xmm0
    vinsertf128    $0x1, %xmm1, %ymm0, %ymm0
    ret

That doesn't really match the code I currently use to do this:
#ifdef __AVX2__
        __m256d d=_mm256_permute4x64_pd(x,1+2*4+3*16+0*64);
#else
        __m256d b=_mm256_shuffle_pd(x,x,5);
        __m256d c=_mm256_permute2f128_pd(b,b,1);
        __m256d d=_mm256_blend_pd(b,c,10);
#endif

Could something recognizing this permutation pattern (and the right cyclic
shift) be added? I know there are too many shuffles to hand-code them all, but
cycles seem like they shouldn't be too uncommon.

With -mavx2, I get a single vpermq, which is close enough to the expected
vpermpd.


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

* [Bug c/52577] __builtin_shuffle -Wunused-but-set-* false positives
  2012-03-13  8:33 [Bug c/52577] New: __builtin_shuffle -Wunused-but-set-* false positives jakub at gcc dot gnu.org
@ 2012-03-13  8:36 ` jakub at gcc dot gnu.org
  2012-03-13  8:59 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-13  8:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52577

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-03-13
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |
   Target Milestone|---                         |4.7.1
     Ever Confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-13 08:35:58 UTC ---
Testcase for the false positive warnings:

/* PR c/52577 */
/* { dg-do compile } */
/* { dg-options "-Wall" } */

typedef int V __attribute__((vector_size (sizeof (int) * 4)));

void
f1 (V *p)
{
  V mask = { 1, 2, 3, 0 };
  *p = __builtin_shuffle (*p, mask);
}

void
f2 (V *p, V *q)
{
  V mask = { 1, 2, 3, 0 };
  *p = __builtin_shuffle (*p, *q, mask);
}

void
f3 (V *p, V *mask)
{
  V a = { 1, 2, 3, 0 };
  *p = __builtin_shuffle (a, *mask);
}

void
f4 (V *p, V *mask)
{
  V a = { 1, 2, 3, 0 };
  V b = { 2, 3, 4, 1 };
  *p = __builtin_shuffle (a, b, *mask);
}


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

* [Bug c/52577] __builtin_shuffle -Wunused-but-set-* false positives
  2012-03-13  8:33 [Bug c/52577] New: __builtin_shuffle -Wunused-but-set-* false positives jakub at gcc dot gnu.org
  2012-03-13  8:36 ` [Bug c/52577] " jakub at gcc dot gnu.org
@ 2012-03-13  8:59 ` jakub at gcc dot gnu.org
  2012-03-13 21:25 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-13  8:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52577

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-13 08:59:11 UTC ---
Created attachment 26884
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26884
gcc47-pr52577.patch

Untested fix.


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

* [Bug c/52577] __builtin_shuffle -Wunused-but-set-* false positives
  2012-03-13  8:33 [Bug c/52577] New: __builtin_shuffle -Wunused-but-set-* false positives jakub at gcc dot gnu.org
  2012-03-13  8:36 ` [Bug c/52577] " jakub at gcc dot gnu.org
  2012-03-13  8:59 ` jakub at gcc dot gnu.org
@ 2012-03-13 21:25 ` jakub at gcc dot gnu.org
  2012-03-22 10:11 ` jakub at gcc dot gnu.org
  2012-03-22 10:12 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-13 21:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52577

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-13 21:19:56 UTC ---
Author: jakub
Date: Tue Mar 13 21:19:50 2012
New Revision: 185355

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185355
Log:
    PR c/52577
    * c-parser.c (c_parser_postfix_expression)
    <case RID_BUILTIN_SHUFFLE>: Call mark_exp_read on argument values.

    * gcc.dg/Wunused-var-3.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/Wunused-var-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-parser.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c/52577] __builtin_shuffle -Wunused-but-set-* false positives
  2012-03-13  8:33 [Bug c/52577] New: __builtin_shuffle -Wunused-but-set-* false positives jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-03-13 21:25 ` jakub at gcc dot gnu.org
@ 2012-03-22 10:11 ` jakub at gcc dot gnu.org
  2012-03-22 10:12 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-22 10:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52577

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-22 10:08:56 UTC ---
Author: jakub
Date: Thu Mar 22 10:08:49 2012
New Revision: 185682

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185682
Log:
    Backported from mainline
    2012-03-13  Jakub Jelinek  <jakub@redhat.com>

    PR c/52577
    * c-parser.c (c_parser_postfix_expression)
    <case RID_BUILTIN_SHUFFLE>: Call mark_exp_read on argument values.

    * gcc.dg/Wunused-var-3.c: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/Wunused-var-3.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/c-parser.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


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

* [Bug c/52577] __builtin_shuffle -Wunused-but-set-* false positives
  2012-03-13  8:33 [Bug c/52577] New: __builtin_shuffle -Wunused-but-set-* false positives jakub at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-03-22 10:11 ` jakub at gcc dot gnu.org
@ 2012-03-22 10:12 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-22 10:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52577

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-22 10:11:21 UTC ---
Fixed.


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

end of thread, other threads:[~2012-03-22 10:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13  8:33 [Bug c/52577] New: __builtin_shuffle -Wunused-but-set-* false positives jakub at gcc dot gnu.org
2012-03-13  8:36 ` [Bug c/52577] " jakub at gcc dot gnu.org
2012-03-13  8:59 ` jakub at gcc dot gnu.org
2012-03-13 21:25 ` jakub at gcc dot gnu.org
2012-03-22 10:11 ` jakub at gcc dot gnu.org
2012-03-22 10:12 ` 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).