public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/52577] New: __builtin_shuffle -Wunused-but-set-* false positives
Date: Tue, 13 Mar 2012 08:33:00 -0000	[thread overview]
Message-ID: <bug-52577-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2012-03-13  8:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13  8:33 jakub at gcc dot gnu.org [this message]
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

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-52577-4@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).