[x86_64] Fix PR87853, _mm_cmpgt_epi8 broken with -funsigned-char

Message ID CAATtE7D09qJtVneNkDF-nHvbBELmQT6HU6mVE5g71=GxONV6Tg@mail.gmail.com
State New
Headers show
Series
  • [x86_64] Fix PR87853, _mm_cmpgt_epi8 broken with -funsigned-char
Related show

Commit Message

Terry Guo Nov. 5, 2018, 1:58 a.m.
Hi there,

This patch intends to fix PR87853 by involving a new 'signed char'
vector type to avoid the impact of option -funsigned-char. Tested with
bootstrap and regression tests on x86_64. No regressions.

Is it OK to trunk and release branch?

BR,
Terry

 /* The Intel API is flexible enough that we must allow aliasing with other
@@ -1295,7 +1296,7 @@ _mm_xor_si128 (__m128i __A, __m128i __B)
 extern __inline __m128i __attribute__((__gnu_inline__,
__always_inline__, __artificial__))
 _mm_cmpeq_epi8 (__m128i __A, __m128i __B)
 {
-  return (__m128i) ((__v16qi)__A == (__v16qi)__B);
+  return (__m128i) ((__v16qs)__A == (__v16qs)__B);
 }

 extern __inline __m128i __attribute__((__gnu_inline__,
__always_inline__, __artificial__))
@@ -1313,7 +1314,7 @@ _mm_cmpeq_epi32 (__m128i __A, __m128i __B)
 extern __inline __m128i __attribute__((__gnu_inline__,
__always_inline__, __artificial__))
 _mm_cmplt_epi8 (__m128i __A, __m128i __B)
 {
-  return (__m128i) ((__v16qi)__A < (__v16qi)__B);
+  return (__m128i) ((__v16qs)__A < (__v16qs)__B);
 }

 extern __inline __m128i __attribute__((__gnu_inline__,
__always_inline__, __artificial__))
@@ -1331,7 +1332,7 @@ _mm_cmplt_epi32 (__m128i __A, __m128i __B)
 extern __inline __m128i __attribute__((__gnu_inline__,
__always_inline__, __artificial__))
 _mm_cmpgt_epi8 (__m128i __A, __m128i __B)
 {
-  return (__m128i) ((__v16qi)__A > (__v16qi)__B);
+  return (__m128i) ((__v16qs)__A > (__v16qs)__B);
 }

 extern __inline __m128i __attribute__((__gnu_inline__,
__always_inline__, __artificial__))

Comments

Uros Bizjak Nov. 5, 2018, 7 a.m. | #1
On Mon, Nov 5, 2018 at 2:58 AM Terry Guo <terry.xpguo@gmail.com> wrote:
>

> Hi there,

>

> This patch intends to fix PR87853 by involving a new 'signed char'

> vector type to avoid the impact of option -funsigned-char. Tested with

> bootstrap and regression tests on x86_64. No regressions.

>

> Is it OK to trunk and release branch?

>

> BR,

> Terry

>

> diff --git a/gcc/ChangeLog b/gcc/ChangeLog

> index ac121a8..dc10a11 100644

> --- a/gcc/ChangeLog

> +++ b/gcc/ChangeLog

> @@ -1,3 +1,12 @@

> +2018-11-05  Xuepeng Guo  <xuepeng.guo@intel.com>

> +

> +       PR target/87853

> +       * config/i386/emmintrin.h (__v16qs): New to cope with option

> +       -funsigned-char.

> +       (_mm_cmpeq_epi8): Replace __v16qi with __v16qs.

> +       (_mm_cmplt_epi8): Likewise.

> +       (_mm_cmpgt_epi8): Likewise.


OK everywhere.

Thanks,
Uros.

>  2018-11-04  Bernd Edlinger  <bernd.edlinger@hotmail.de>

>

>         PR tree-optimization/86572

> diff --git a/gcc/config/i386/emmintrin.h b/gcc/config/i386/emmintrin.h

> index 7a6ff80..3c1f04b 100644

> --- a/gcc/config/i386/emmintrin.h

> +++ b/gcc/config/i386/emmintrin.h

> @@ -45,6 +45,7 @@ typedef unsigned int __v4su __attribute__

> ((__vector_size__ (16)));

>  typedef short __v8hi __attribute__ ((__vector_size__ (16)));

>  typedef unsigned short __v8hu __attribute__ ((__vector_size__ (16)));

>  typedef char __v16qi __attribute__ ((__vector_size__ (16)));

> +typedef signed char __v16qs __attribute__ ((__vector_size__ (16)));

>  typedef unsigned char __v16qu __attribute__ ((__vector_size__ (16)));

>

>  /* The Intel API is flexible enough that we must allow aliasing with other

> @@ -1295,7 +1296,7 @@ _mm_xor_si128 (__m128i __A, __m128i __B)

>  extern __inline __m128i __attribute__((__gnu_inline__,

> __always_inline__, __artificial__))

>  _mm_cmpeq_epi8 (__m128i __A, __m128i __B)

>  {

> -  return (__m128i) ((__v16qi)__A == (__v16qi)__B);

> +  return (__m128i) ((__v16qs)__A == (__v16qs)__B);

>  }

>

>  extern __inline __m128i __attribute__((__gnu_inline__,

> __always_inline__, __artificial__))

> @@ -1313,7 +1314,7 @@ _mm_cmpeq_epi32 (__m128i __A, __m128i __B)

>  extern __inline __m128i __attribute__((__gnu_inline__,

> __always_inline__, __artificial__))

>  _mm_cmplt_epi8 (__m128i __A, __m128i __B)

>  {

> -  return (__m128i) ((__v16qi)__A < (__v16qi)__B);

> +  return (__m128i) ((__v16qs)__A < (__v16qs)__B);

>  }

>

>  extern __inline __m128i __attribute__((__gnu_inline__,

> __always_inline__, __artificial__))

> @@ -1331,7 +1332,7 @@ _mm_cmplt_epi32 (__m128i __A, __m128i __B)

>  extern __inline __m128i __attribute__((__gnu_inline__,

> __always_inline__, __artificial__))

>  _mm_cmpgt_epi8 (__m128i __A, __m128i __B)

>  {

> -  return (__m128i) ((__v16qi)__A > (__v16qi)__B);

> +  return (__m128i) ((__v16qs)__A > (__v16qs)__B);

>  }

>

>  extern __inline __m128i __attribute__((__gnu_inline__,

> __always_inline__, __artificial__))

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ac121a8..dc10a11 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@ 
+2018-11-05  Xuepeng Guo  <xuepeng.guo@intel.com>
+
+       PR target/87853
+       * config/i386/emmintrin.h (__v16qs): New to cope with option
+       -funsigned-char.
+       (_mm_cmpeq_epi8): Replace __v16qi with __v16qs.
+       (_mm_cmplt_epi8): Likewise.
+       (_mm_cmpgt_epi8): Likewise.
+
 2018-11-04  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR tree-optimization/86572
diff --git a/gcc/config/i386/emmintrin.h b/gcc/config/i386/emmintrin.h
index 7a6ff80..3c1f04b 100644
--- a/gcc/config/i386/emmintrin.h
+++ b/gcc/config/i386/emmintrin.h
@@ -45,6 +45,7 @@  typedef unsigned int __v4su __attribute__
((__vector_size__ (16)));
 typedef short __v8hi __attribute__ ((__vector_size__ (16)));
 typedef unsigned short __v8hu __attribute__ ((__vector_size__ (16)));
 typedef char __v16qi __attribute__ ((__vector_size__ (16)));
+typedef signed char __v16qs __attribute__ ((__vector_size__ (16)));
 typedef unsigned char __v16qu __attribute__ ((__vector_size__ (16)));