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] |
Hi, all one m128i constant can be materialized using pcmpeqd instruction (compared with a memory load from rodata). This patch implements this. Bootstrapped/regression tested on linux-i686. Ok to commit? Thanks, David
Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 145332) +++ config/i386/i386.c (working copy) @@ -8951,7 +8951,8 @@ legitimate_constant_p (rtx x) break; case CONST_VECTOR: - if (x == CONST0_RTX (GET_MODE (x))) + if (x == CONST0_RTX (GET_MODE (x)) + || (vector_all_ones_operand (x, GET_MODE (x)) && TARGET_SSE)) return true; return false; Index: testsuite/gcc.dg/all_one_m128i.c =================================================================== --- testsuite/gcc.dg/all_one_m128i.c (revision 0) +++ testsuite/gcc.dg/all_one_m128i.c (revision 0) @@ -0,0 +1,41 @@ +/* { dg-do run { target x86_64-*-* i?86-*-* } } */ +/* { dg-options "-save-temps -O2 -msse2" } */ + + +#include <stdio.h> +#include <xmmintrin.h> +#include <emmintrin.h> +__m128i m; +__m128i m2; +__attribute__((noinline)) __m128i foo() +{ + __m128i minus_1 = __extension__(__m128i)(__v4si){-1,-1,-1,-1}; + m = minus_1; + return minus_1; +} + + +int main () +{ + unsigned *p, *p2; + p = (unsigned *)&m; + p2 =(unsigned *)&m2; + m2 = foo(); + + if (p[0] != (unsigned)-1 + || p[1] != (unsigned) -1 + || p[2] != (unsigned) -1 + || p[3] != (unsigned) -1) + return 1; + + if (p2[0] != (unsigned)-1 + || p2[1] != (unsigned) -1 + || p2[2] != (unsigned) -1 + || p2[3] != (unsigned) -1) + return 2; + + return 0; +} + +/* { dg-final { scan-assembler "pcmpeqd" } } */ +/* { dg-final { cleanup-saved-temps } } */
Attachment:
cl5
Description: Binary data
Attachment:
cl5
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |