From ab3146fde752eef940f3724226a59f12a71f2750 Mon Sep 17 00:00:00 2001 From: Zdenek Dvorak Date: Sun, 20 Oct 2002 22:38:41 +0200 Subject: re PR other/8202 (_mm_srli_si128 and _mm_slli_si128 missing from xmmintrin.h) PR other/8202 * i386.c (ix86_init_mmx_sse_builtins, ix86_expand_builtin): Define and expand __builtin_ia32_pslldqi128 and __builtin_ia32_psrldqi128. * i386.h (IX86_BUILTIN_PSLLDQI128, IX86_BUILTIN_PSRLDQI128): New. * xmmintrin.h (_mm_srli_si128, _mm_slli_si128): New. * testsuite/gcc.dg/i386-sse-3.c: Add tests for _mm_srli_si128 and _mm_slli_si128. From-SVN: r58338 --- gcc/ChangeLog | 8 ++++++++ gcc/config/i386/i386.c | 31 +++++++++++++++++++++++++++++++ gcc/config/i386/i386.h | 2 ++ gcc/config/i386/xmmintrin.h | 16 ++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/i386-sse-3.c | 14 +++++++++++++- 6 files changed, 75 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6f70514..af7f6fd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2002-10-20 Zdenek Dvorak + + PR other/8202 + * i386.c (ix86_init_mmx_sse_builtins, ix86_expand_builtin): Define and + expand __builtin_ia32_pslldqi128 and __builtin_ia32_psrldqi128. + * i386.h (IX86_BUILTIN_PSLLDQI128, IX86_BUILTIN_PSRLDQI128): New. + * xmmintrin.h (_mm_srli_si128, _mm_slli_si128): New. + 2002-10-20 Roger Sayle PR c/761 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 299bd82..0569fef 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -12598,10 +12598,12 @@ ix86_init_mmx_sse_builtins () def_builtin (MASK_SSE2, "__builtin_ia32_psraw128", v8hi_ftype_v8hi_v2di, IX86_BUILTIN_PSRAW128); def_builtin (MASK_SSE2, "__builtin_ia32_psrad128", v4si_ftype_v4si_v2di, IX86_BUILTIN_PSRAD128); + def_builtin (MASK_SSE2, "__builtin_ia32_pslldqi128", v2di_ftype_v2di_int, IX86_BUILTIN_PSLLDQI128); def_builtin (MASK_SSE2, "__builtin_ia32_psllwi128", v8hi_ftype_v8hi_int, IX86_BUILTIN_PSLLWI128); def_builtin (MASK_SSE2, "__builtin_ia32_pslldi128", v4si_ftype_v4si_int, IX86_BUILTIN_PSLLDI128); def_builtin (MASK_SSE2, "__builtin_ia32_psllqi128", v2di_ftype_v2di_int, IX86_BUILTIN_PSLLQI128); + def_builtin (MASK_SSE2, "__builtin_ia32_psrldqi128", v2di_ftype_v2di_int, IX86_BUILTIN_PSRLDQI128); def_builtin (MASK_SSE2, "__builtin_ia32_psrlwi128", v8hi_ftype_v8hi_int, IX86_BUILTIN_PSRLWI128); def_builtin (MASK_SSE2, "__builtin_ia32_psrldi128", v4si_ftype_v4si_int, IX86_BUILTIN_PSRLDI128); def_builtin (MASK_SSE2, "__builtin_ia32_psrlqi128", v2di_ftype_v2di_int, IX86_BUILTIN_PSRLQI128); @@ -13186,6 +13188,35 @@ ix86_expand_builtin (exp, target, subtarget, mode, ignore) emit_insn (pat); return target; + case IX86_BUILTIN_PSLLDQI128: + case IX86_BUILTIN_PSRLDQI128: + icode = ( fcode == IX86_BUILTIN_PSLLDQI128 ? CODE_FOR_sse2_ashlti3 + : CODE_FOR_sse2_lshrti3); + arg0 = TREE_VALUE (arglist); + arg1 = TREE_VALUE (TREE_CHAIN (arglist)); + op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0); + op1 = expand_expr (arg1, NULL_RTX, VOIDmode, 0); + tmode = insn_data[icode].operand[0].mode; + mode1 = insn_data[icode].operand[1].mode; + mode2 = insn_data[icode].operand[2].mode; + + if (! (*insn_data[icode].operand[1].predicate) (op0, mode1)) + { + op0 = copy_to_reg (op0); + op0 = simplify_gen_subreg (mode1, op0, GET_MODE (op0), 0); + } + if (! (*insn_data[icode].operand[2].predicate) (op1, mode2)) + { + error ("shift must be an immediate"); + return const0_rtx; + } + target = gen_reg_rtx (V2DImode); + pat = GEN_FCN (icode) (simplify_gen_subreg (tmode, target, V2DImode, 0), op0, op1); + if (! pat) + return 0; + emit_insn (pat); + return target; + case IX86_BUILTIN_FEMMS: emit_insn (gen_femms ()); return NULL_RTX; diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 4c38989..56ccf4e 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2402,11 +2402,13 @@ enum ix86_builtins IX86_BUILTIN_PSRLW128, IX86_BUILTIN_PSRLD128, IX86_BUILTIN_PSRLQ128, + IX86_BUILTIN_PSLLDQI128, IX86_BUILTIN_PSLLWI128, IX86_BUILTIN_PSLLDI128, IX86_BUILTIN_PSLLQI128, IX86_BUILTIN_PSRAWI128, IX86_BUILTIN_PSRADI128, + IX86_BUILTIN_PSRLDQI128, IX86_BUILTIN_PSRLWI128, IX86_BUILTIN_PSRLDI128, IX86_BUILTIN_PSRLQI128, diff --git a/gcc/config/i386/xmmintrin.h b/gcc/config/i386/xmmintrin.h index 42278b7..8c5d41b 100644 --- a/gcc/config/i386/xmmintrin.h +++ b/gcc/config/i386/xmmintrin.h @@ -1979,6 +1979,22 @@ _mm_srai_epi32 (__m128i __A, int __B) return (__m128i)__builtin_ia32_psradi128 ((__v4si)__A, __B); } +#if 0 +static __m128i __attribute__((__always_inline__)) +_mm_srli_si128 (__m128i __A, const int __B) +{ + return ((__m128i)__builtin_ia32_psrldqi128 (__A, __B)) +} + +static __m128i __attribute__((__always_inline__)) +_mm_srli_si128 (__m128i __A, const int __B) +{ + return ((__m128i)__builtin_ia32_pslldqi128 (__A, __B)) +} +#endif +#define _mm_srli_si128(__A, __B) ((__m128i)__builtin_ia32_psrldqi128 (__A, __B)) +#define _mm_slli_si128(__A, __B) ((__m128i)__builtin_ia32_pslldqi128 (__A, __B)) + static __inline __m128i _mm_srli_epi16 (__m128i __A, int __B) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 83d9bf7..49e3d4b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-10-20 Zdenek Dvorak + + * testsuite/gcc.dg/i386-sse-3.c: Add tests for _mm_srli_si128 and + _mm_slli_si128. + 2002-10-19 Andreas Schwab * lib/compat.exp (compat-run): Prepend "./" when $dest has no diff --git a/gcc/testsuite/gcc.dg/i386-sse-3.c b/gcc/testsuite/gcc.dg/i386-sse-3.c index d67a591..9f31cfa 100644 --- a/gcc/testsuite/gcc.dg/i386-sse-3.c +++ b/gcc/testsuite/gcc.dg/i386-sse-3.c @@ -1,5 +1,5 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ -/* { dg-options "-O2 -msse" } */ +/* { dg-options "-O2 -msse -msse2" } */ /* Test that the intrinsics compile with optimization. These were not tested in i386-sse-[12].c because these builtins require immediate @@ -35,3 +35,15 @@ test_prefetch (char *p) _mm_prefetch (p+8, _MM_HINT_T2); _mm_prefetch (p+12, _MM_HINT_NTA); } + +__m128i +test__slli_si128 (__m128i a) +{ + return _mm_slli_si128 (a, 3); +} + +__m128i +test__srli_si128 (__m128i a) +{ + return _mm_srli_si128 (a, 3); +} -- cgit v1.1