Compiling the following with "g++ -msse3 -O3":

#include <emmintrin.h>
int foo(__m128i* val) {
  return __builtin_ia32_vec_ext_v4si(*val, 1);
}
int bar(__m128i* val) {
  union vs {
    __m128i *_v;
    int* _s;
  } v = {val};
  return v._s[1];
}

yields the following assembler output. Ideally, both functions would be the
same:

_Z3fooPU8__vectorx:
.LFB497:
        pshufd  $85, (%rdi), %xmm0
        movd    %xmm0, %rax
        movq    %xmm0, -8(%rsp)
        ret
_Z3barPU8__vectorx:
.LFB498:
        movl    4(%rdi), %eax
        ret


-- 
           Summary: __builtin_ia32_vec_ext suboptimal for pointer/ref args
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: scovich at gmail dot com
GCC target triplet: x86_64-linux-gnu


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

Reply via email to