This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Optimize vector set for SSE4.1


Hi,

This patch optimizes vector set for SSE4.1:

[hjl@gnu-6 sse-1]$ cat v16qi-3.c
#include <emmintrin.h>

__m128i
foo2 (char x)
{
  return _mm_set_epi8 (1, 0, 0, 0, 0, 0, 0, 0, 0, x, 0, 1, 0, 0, 0, 0);
}
[hjl@gnu-6 sse-1]$ /usr/gcc-4.4/bin/gcc -O2 -S -march=core2 -msse4
v16qi-3.c -fno-asynchronous-unwind-tables
[hjl@gnu-6 sse-1]$ cat v16qi-3.s
        .file   "v16qi-3.c"
        .text
        .p2align 4,,15
.globl foo2
        .type   foo2, @function
foo2:
        movzbl  %dil, %edi
        movdqa  .LC0(%rip), %xmm0
        pinsrw  $3, %edi, %xmm0
        ret
[hjl@gnu-6 sse-1]$
/export/build/gnu/gcc-fsf/build-x86_64-linux/gcc/xgcc -B./
-B/export/build/gnu/gcc-fsf/build-x86_64-linux/gcc/  -O2 -S
-march=core2 -msse4 v16qi-3.c -fno-asynchronous-unwind-tables
[hjl@gnu-6 sse-1]$ cat v16qi-3.s
        .file   "v16qi-3.c"
        .text
        .p2align 4,,15
.globl foo2
        .type   foo2, @function
foo2:
        movdqa  .LC0(%rip), %xmm0
        pinsrb  $6, %edi, %xmm0
        ret

OK for mainline?

Thanks.


H.J.
----
gcc/

2008-05-21  H.J. Lu  <hongjiu.lu@intel.com>

        * config/i386/i386.c (ix86_expand_vector_init_one_var): Use
        ix86_expand_vector_set V16QImode for SSE4.1.

gcc/testsuite

2008-05-21  H.J. Lu  <hongjiu.lu@intel.com>

        * gcc.target/i386/m128-check.h (ARRAY_SIZE): New.
        (CHECK_EXP): Use it.

        * gcc.target/i386/set-v16qi-3.h: New.
        * gcc.target/i386/sse2-set-v16qi-3.c: Likewise.
        * gcc.target/i386/sse4_1-set-v16qi-3.c: Likewise.

Attachment: b.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]