x86: Cast to unsigned short first for _mm_extract_pi16
_mm_extract_pi16 is intrinsic for pextrw, which should be zero-extended, not sign-extended. gcc/ PR target/98495 * config/i386/xmmintrin.h (_mm_extract_pi16): Cast to unsigned short first. gcc/testsuite/ PR target/98495 * gcc.target/i386/pr98495-1.c: New test. * gcc.target/i386/pr98495-2.c: New test. * gcc.target/i386/pr98495-3.c: New test. * gcc.target/i386/pr98495-4.c: New test. * gcc.target/i386/pr98495-5.c: New test.
This commit is contained in:
parent
b679559385
commit
af60b0ec79
@ -1022,7 +1022,7 @@ _mm_move_ss (__m128 __A, __m128 __B)
|
||||
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
|
||||
_mm_extract_pi16 (__m64 const __A, int const __N)
|
||||
{
|
||||
return __builtin_ia32_vec_ext_v4hi ((__v4hi)__A, __N);
|
||||
return (unsigned short) __builtin_ia32_vec_ext_v4hi ((__v4hi)__A, __N);
|
||||
}
|
||||
|
||||
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
|
||||
@ -1032,7 +1032,7 @@ _m_pextrw (__m64 const __A, int const __N)
|
||||
}
|
||||
#else
|
||||
#define _mm_extract_pi16(A, N) \
|
||||
((int) __builtin_ia32_vec_ext_v4hi ((__v4hi)(__m64)(A), (int)(N)))
|
||||
((int) (unsigned short) __builtin_ia32_vec_ext_v4hi ((__v4hi)(__m64)(A), (int)(N)))
|
||||
|
||||
#define _m_pextrw(A, N) _mm_extract_pi16(A, N)
|
||||
#endif
|
||||
|
10
gcc/testsuite/gcc.target/i386/pr98495-1.c
Normal file
10
gcc/testsuite/gcc.target/i386/pr98495-1.c
Normal file
@ -0,0 +1,10 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -mmmx -msse2 -mtune=generic" } */
|
||||
/* { dg-final { scan-assembler-not "movswl" } } */
|
||||
/* { dg-final { scan-assembler-not "movzwl" } } */
|
||||
/* { dg-final { scan-assembler-not "cwtl" } } */
|
||||
/* { dg-final { scan-assembler "pextrw" } } */
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
unsigned int foo16(__m64 x) { return _mm_extract_pi16(x, 3); }
|
11
gcc/testsuite/gcc.target/i386/pr98495-2.c
Normal file
11
gcc/testsuite/gcc.target/i386/pr98495-2.c
Normal file
@ -0,0 +1,11 @@
|
||||
/* { dg-do compile { target { ! ia32 } } } */
|
||||
/* { dg-options "-O2 -mmmx -msse2 -mtune=generic" } */
|
||||
/* { dg-final { scan-assembler-not "movswl" } } */
|
||||
/* { dg-final { scan-assembler-not "movzwl" } } */
|
||||
/* { dg-final { scan-assembler-not "cwtl" } } */
|
||||
/* { dg-final { scan-assembler-not "cltq" } } */
|
||||
/* { dg-final { scan-assembler "pextrw" } } */
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
unsigned long long int foo16(__m64 x) { return _mm_extract_pi16(x, 3); }
|
8
gcc/testsuite/gcc.target/i386/pr98495-3.c
Normal file
8
gcc/testsuite/gcc.target/i386/pr98495-3.c
Normal file
@ -0,0 +1,8 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -mmmx -msse2 -mtune=generic" } */
|
||||
/* { dg-final { scan-assembler "(movswl|cwtl)" } } */
|
||||
/* { dg-final { scan-assembler "pextrw" } } */
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
int foo16(__m64 x) { return (short) _mm_extract_pi16(x, 3); }
|
8
gcc/testsuite/gcc.target/i386/pr98495-4.c
Normal file
8
gcc/testsuite/gcc.target/i386/pr98495-4.c
Normal file
@ -0,0 +1,8 @@
|
||||
/* { dg-do compile { target { ! ia32 } } } */
|
||||
/* { dg-options "-O2 -mmmx -msse2 -mtune=generic" } */
|
||||
/* { dg-final { scan-assembler "movswq" } } */
|
||||
/* { dg-final { scan-assembler "pextrw" } } */
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
long long int foo16(__m64 x) { return (short) _mm_extract_pi16(x, 3); }
|
9
gcc/testsuite/gcc.target/i386/pr98495-5.c
Normal file
9
gcc/testsuite/gcc.target/i386/pr98495-5.c
Normal file
@ -0,0 +1,9 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O0 -mmmx -msse2 -mtune=generic" } */
|
||||
/* { dg-final { scan-assembler-not "movswl" } } */
|
||||
/* { dg-final { scan-assembler-not "cwtl" } } */
|
||||
/* { dg-final { scan-assembler "pextrw" } } */
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
unsigned int foo16(__m64 x) { return _mm_extract_pi16(x, 3); }
|
Loading…
Reference in New Issue
Block a user