public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, rs6000] Fix _mm_extract_pi16 for big-endian
@ 2018-10-25 19:08 Paul Clarke
  2018-10-25 22:34 ` Segher Boessenkool
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Clarke @ 2018-10-25 19:08 UTC (permalink / raw)
  To: gcc-patches, Segher Boessenkool

For compatibility implementation of x86 vector intrinsic, _mm_extract_pi16,
adjust shift value for big-endian mode.

Bootstrapped and tested on Linux POWER8 LE, POWER8 BE (64 & 32), and POWER7.

OK for trunk?

gcc/ChangeLog:

2018-10-25  Paul A. Clarke  <pc@us.ibm.com>

	* config/rs6000/xmmintrin.h: Fix _mm_extract_pi16 for big-endian.

diff --git a/trunk/gcc/config/rs6000/xmmintrin.h b/trunk/gcc/config/rs6000/xmmintrin.h
--- a/trunk/gcc/config/rs6000/xmmintrin.h	(revision 265238)
+++ b/trunk/gcc/config/rs6000/xmmintrin.h	(working copy)
@@ -1386,9 +1385,12 @@
 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 _mm_extract_pi16 (__m64 const __A, int const __N)
 {
-  const int shiftr = (__N & 3) * 16;
+  unsigned int shiftr = __N & 3;
+#ifdef __BIG_ENDIAN__
+  shiftr = 3 - shiftr;
+#endif
 
-  return ((__A >> shiftr) & 0xffff);
+  return ((__A >> (shiftr * 16)) & 0xffff);
 }
 
 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, rs6000] Fix _mm_extract_pi16 for big-endian
  2018-10-25 19:08 [PATCH, rs6000] Fix _mm_extract_pi16 for big-endian Paul Clarke
@ 2018-10-25 22:34 ` Segher Boessenkool
  2018-10-25 22:42   ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2018-10-25 22:34 UTC (permalink / raw)
  To: Paul Clarke; +Cc: gcc-patches

On Thu, Oct 25, 2018 at 01:41:15PM -0500, Paul Clarke wrote:
> For compatibility implementation of x86 vector intrinsic, _mm_extract_pi16,
> adjust shift value for big-endian mode.
> 
> Bootstrapped and tested on Linux POWER8 LE, POWER8 BE (64 & 32), and POWER7.

Does it fix existing testcases?

Okay for trunk in either case.  Thanks!  Also fine to backport to 8.


Segher


> 2018-10-25  Paul A. Clarke  <pc@us.ibm.com>
> 
> 	* config/rs6000/xmmintrin.h: Fix _mm_extract_pi16 for big-endian.
> 
> diff --git a/trunk/gcc/config/rs6000/xmmintrin.h b/trunk/gcc/config/rs6000/xmmintrin.h
> --- a/trunk/gcc/config/rs6000/xmmintrin.h	(revision 265238)
> +++ b/trunk/gcc/config/rs6000/xmmintrin.h	(working copy)
> @@ -1386,9 +1385,12 @@
>  extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
>  _mm_extract_pi16 (__m64 const __A, int const __N)
>  {
> -  const int shiftr = (__N & 3) * 16;
> +  unsigned int shiftr = __N & 3;
> +#ifdef __BIG_ENDIAN__
> +  shiftr = 3 - shiftr;
> +#endif
>  
> -  return ((__A >> shiftr) & 0xffff);
> +  return ((__A >> (shiftr * 16)) & 0xffff);
>  }
>  
>  extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, rs6000] Fix _mm_extract_pi16 for big-endian
  2018-10-25 22:34 ` Segher Boessenkool
@ 2018-10-25 22:42   ` Jakub Jelinek
  2018-10-26 14:20     ` Paul Clarke
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2018-10-25 22:42 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Paul Clarke, gcc-patches

On Thu, Oct 25, 2018 at 05:07:03PM -0500, Segher Boessenkool wrote:
> On Thu, Oct 25, 2018 at 01:41:15PM -0500, Paul Clarke wrote:
> > For compatibility implementation of x86 vector intrinsic, _mm_extract_pi16,
> > adjust shift value for big-endian mode.
> > 
> > Bootstrapped and tested on Linux POWER8 LE, POWER8 BE (64 & 32), and POWER7.
> 
> Does it fix existing testcases?
> 
> Okay for trunk in either case.  Thanks!  Also fine to backport to 8.
> 
> 
> Segher
> 
> 
> > 2018-10-25  Paul A. Clarke  <pc@us.ibm.com>
> > 
> > 	* config/rs6000/xmmintrin.h: Fix _mm_extract_pi16 for big-endian.

The ChangeLog entry is incorrect, should be:
	* config/rs6000/xmmintrin.h (_mm_extract_pi16): Fix for big-endian.
or so.

	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, rs6000] Fix _mm_extract_pi16 for big-endian
  2018-10-25 22:42   ` Jakub Jelinek
@ 2018-10-26 14:20     ` Paul Clarke
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Clarke @ 2018-10-26 14:20 UTC (permalink / raw)
  To: Jakub Jelinek, Segher Boessenkool; +Cc: gcc-patches

On 10/25/2018 05:08 PM, Jakub Jelinek wrote:
> On Thu, Oct 25, 2018 at 05:07:03PM -0500, Segher Boessenkool wrote:
>> On Thu, Oct 25, 2018 at 01:41:15PM -0500, Paul Clarke wrote:
>>> For compatibility implementation of x86 vector intrinsic, _mm_extract_pi16,
>>> adjust shift value for big-endian mode.
>>>
>>> Bootstrapped and tested on Linux POWER8 LE, POWER8 BE (64 & 32), and POWER7.
>>
>> Does it fix existing testcases?

No. I found it with my own testing. I have a "to-do" to enhance the testing in this area, not only for endian issues, but I think corner/edge cases are not well tested.

>> Okay for trunk in either case.  Thanks!  Also fine to backport to 8.

Thanks!

>>> 2018-10-25  Paul A. Clarke  <pc@us.ibm.com>
>>>
>>> 	* config/rs6000/xmmintrin.h: Fix _mm_extract_pi16 for big-endian.
> 
> The ChangeLog entry is incorrect, should be:
> 	* config/rs6000/xmmintrin.h (_mm_extract_pi16): Fix for big-endian.
> or so.

Will fix before committing. Thanks!

PC

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-26 12:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25 19:08 [PATCH, rs6000] Fix _mm_extract_pi16 for big-endian Paul Clarke
2018-10-25 22:34 ` Segher Boessenkool
2018-10-25 22:42   ` Jakub Jelinek
2018-10-26 14:20     ` Paul Clarke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).