Re: [PATCH 2/3][rs6000] Fix x86-compat vector intrinsics testcases for BE, 32bit

2018-12-04 Thread Segher Boessenkool
Hi!

On Tue, Dec 04, 2018 at 08:59:40AM -0600, Paul Clarke wrote:
> Fix general endian issues found in the test cases for the compatibility
> implementations of the x86 vector intrinsics.  (The tests had been
> inadvertently made to PASS without actually running the test code.
> A later patch fixes this issue.)
> 
> Additionally, a new  is added, as some of the APIs therein are
> now used by the test cases.  It is _not_ a complete implementation of the
> SSE4 interfaces, only the few "extract" interfaces uses by the tests.

Hrm.  We probably should tell the user this file isn't the real thing,
somehow.  Could you add a comment in (or near) the header of the file?
I don't think we'll need more, but we'll find out no doubt.

>   PR target/88316
>   * config/rs6000/smmintrin.h: New file.
>   * config.gcc: add smmintrin.h to extra_headers for powerpc*-*-*.

(Capital A).

> [gcc/testsuite]
> 
>   PR target/88316
>   * gcc.target/powerpc/mmx-packssdw-1.c: Fixes for big-endian.
>   * gcc.target/powerpc/mmx-packsswb-1.c: Likewise.
>   * gcc.target/powerpc/mmx-packuswb-1.c: Likewise.
>   * gcc.target/powerpc/mmx-pmulhw-1.c: Likewise.
>   * gcc.target/powerpc/sse-cvtpi32x2ps-1.c: Likewise.
>   * gcc.target/powerpc/sse-cvtpu16ps-1.c: Likewise.
>   * gcc.target/powerpc/sse-cvtss2si-1.c: Likewise.
>   * gcc.target/powerpc/sse-cvtss2si-2.c: Likewise.
>   * gcc.target/powerpc/sse2-pshufhw-1.c: Likewise.
>   * gcc.target/powerpc/sse2-pshuflw-1.c: Likewise.

Okay for trunk with that.  Thanks!


Segher


[PATCH 2/3][rs6000] Fix x86-compat vector intrinsics testcases for BE, 32bit

2018-12-04 Thread Paul Clarke
Fix general endian issues found in the test cases for the compatibility
implementations of the x86 vector intrinsics.  (The tests had been
inadvertently made to PASS without actually running the test code.
A later patch fixes this issue.)

Additionally, a new  is added, as some of the APIs therein are
now used by the test cases.  It is _not_ a complete implementation of the
SSE4 interfaces, only the few "extract" interfaces uses by the tests.

2018-12-03  Paul A. Clarke  

[gcc]

PR target/88316
* config/rs6000/smmintrin.h: New file.
* config.gcc: add smmintrin.h to extra_headers for powerpc*-*-*.

[gcc/testsuite]

PR target/88316
* gcc.target/powerpc/mmx-packssdw-1.c: Fixes for big-endian.
* gcc.target/powerpc/mmx-packsswb-1.c: Likewise.
* gcc.target/powerpc/mmx-packuswb-1.c: Likewise.
* gcc.target/powerpc/mmx-pmulhw-1.c: Likewise.
* gcc.target/powerpc/sse-cvtpi32x2ps-1.c: Likewise.
* gcc.target/powerpc/sse-cvtpu16ps-1.c: Likewise.
* gcc.target/powerpc/sse-cvtss2si-1.c: Likewise.
* gcc.target/powerpc/sse-cvtss2si-2.c: Likewise.
* gcc.target/powerpc/sse2-pshufhw-1.c: Likewise.
* gcc.target/powerpc/sse2-pshuflw-1.c: Likewise.

Index: gcc/config/rs6000/smmintrin.h
===
diff --git a/trunk/gcc/config/rs6000/smmintrin.h 
b/trunk/gcc/config/rs6000/smmintrin.h
new file mode 10644
--- /dev/null   (revision 0)
+++ b/trunk/gcc/config/rs6000/smmintrin.h   (working copy)
@@ -0,0 +1,67 @@
+/* Copyright (C) 2018 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   .  */
+
+/* Implemented from the specification included in the Intel C++ Compiler
+   User Guide and Reference, version 9.0.  */
+
+#ifndef NO_WARN_X86_INTRINSICS
+/* This header is distributed to simplify porting x86_64 code that
+   makes explicit use of Intel intrinsics to powerpc64le.
+   It is the user's responsibility to determine if the results are
+   acceptable and make additional changes as necessary.
+   Note that much code that uses Intel intrinsics can be rewritten in
+   standard C or GNU C extensions, which are more portable and better
+   optimized across multiple targets.  */
+#endif
+
+#ifndef SMMINTRIN_H_
+#define SMMINTRIN_H_
+
+#include 
+#include 
+
+extern __inline int __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))
+_mm_extract_epi8 (__m128i __X, const int __N)
+{
+  return (unsigned char) ((__v16qi)__X)[__N & 15];
+}
+
+extern __inline int __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))
+_mm_extract_epi32 (__m128i __X, const int __N)
+{
+  return ((__v4si)__X)[__N & 3];
+}
+
+extern __inline int __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))
+_mm_extract_epi64 (__m128i __X, const int __N)
+{
+  return ((__v2di)__X)[__N & 1];
+}
+
+extern __inline int __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))
+_mm_extract_ps (__m128 __X, const int __N)
+{
+  return ((__v4si)__X)[__N & 3];
+}
+
+#endif
Index: gcc/config.gcc
===
diff --git a/trunk/gcc/config.gcc b/trunk/gcc/config.gcc
--- a/trunk/gcc/config.gcc  (revision 266157)
+++ b/trunk/gcc/config.gcc  (working copy)
@@ -504,7 +504,7 @@ powerpc*-*-*)
extra_headers="${extra_headers} bmi2intrin.h bmiintrin.h"
extra_headers="${extra_headers} xmmintrin.h mm_malloc.h emmintrin.h"
extra_headers="${extra_headers} mmintrin.h x86intrin.h"
-   extra_headers="${extra_headers} pmmintrin.h tmmintrin.h"
+   extra_headers="${extra_headers} pmmintrin.h tmmintrin.h smmintrin.h"
extra_headers="${extra_headers} ppu_intrinsics.h spu2vmx.h vec_types.h 
si2vmx.h"
extra_headers="${extra_headers} amo.h"
case x$with_cpu in
Index: gcc/testsuite/gcc.target/powerpc/mmx-packssdw-1.c
===
diff --git a/trunk/gcc/testsuite/gcc.target/powerpc/mmx-packssdw-1.c