altivec.h (vec_slv): New macro.
authorKelvin Nilsen <kelvin@gcc.gnu.org>
Wed, 1 Jun 2016 14:01:10 +0000 (14:01 +0000)
committerKelvin Nilsen <kelvin@gcc.gnu.org>
Wed, 1 Jun 2016 14:01:10 +0000 (14:01 +0000)
gcc/ChangeLog:

2016-06-01  Kelvin Nilsen  <kelvin@gcc.gnu.org>

* config/rs6000/altivec.h (vec_slv): New macro.
(vec_srv): New macro.
* config/rs6000/altivec.md (UNSPEC_VSLV): New value.
(UNSPEC_VSRV): New value.
(vslv): New insn.
(vsrv): New insn.
* config/rs6000/rs6000-builtin.def (vslv): New builtin definition.
(vsrv): New builtin definition.
* config/rs6000/rs6000-c.c (P9V_BUILTIN_VSLV): Macro expansion to
define argument types for new builtin.
(P9V_BUILTIN_VSRV): Macro expansion to define argument types for
new builtin.
* doc/extend.texi: Document the new vec_vslv and vec_srv built-in
functions.

gcc/testsuite/ChangeLog:

2016-06-01  Kelvin Nilsen  <kelvin@gcc.gnu.org>

* gcc.target/powerpc/vslv-0.c: New test.
* gcc.target/powerpc/vslv-1.c: New test.
* gcc.target/powerpc/vsrv-0.c: New test.
* gcc.target/powerpc/vsrv-1.c: New test.

From-SVN: r236992

gcc/ChangeLog
gcc/config/rs6000/altivec.h
gcc/config/rs6000/altivec.md
gcc/config/rs6000/rs6000-builtin.def
gcc/config/rs6000/rs6000-c.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/vslv-0.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/vslv-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/vsrv-0.c [new file with mode: 0644]
gcc/testsuite/gcc.target/powerpc/vsrv-1.c [new file with mode: 0644]

index 59dda4df2005c4d94beb5782bd857d4ab433f0dc..19c9679af5ed0b6eaa1e09de0138d654a22f400d 100644 (file)
@@ -1,3 +1,20 @@
+2016-06-01  Kelvin Nilsen  <kelvin@gcc.gnu.org>
+
+       * config/rs6000/altivec.h (vec_slv): New macro.
+       (vec_srv): New macro.
+       * config/rs6000/altivec.md (UNSPEC_VSLV): New value.
+       (UNSPEC_VSRV): New value.
+       (vslv): New insn.
+       (vsrv): New insn.
+       * config/rs6000/rs6000-builtin.def (vslv): New builtin definition.
+       (vsrv): New builtin definition.
+       * config/rs6000/rs6000-c.c (P9V_BUILTIN_VSLV): Macro expansion to
+       define argument types for new builtin.
+       (P9V_BUILTIN_VSRV): Macro expansion to define argument types for
+       new builtin.
+       * doc/extend.texi: Document the new vec_vslv and vec_srv built-in
+       functions. 
+
 2016-06-01  Uros Bizjak  <ubizjak@gmail.com>
            Jocelyn Mayer  <l_indien@magic.fr>
 
index 7289cd596b4939ed0e553b7695eeb396d0990216..7e42aefe4c60ce6b1c74eb18605d8409512a6bfd 100644 (file)
 #ifdef _ARCH_PPC64
 #define vec_vprtybq __builtin_vec_vprtybq
 #endif
+
+#define vec_slv __builtin_vec_vslv
+#define vec_srv __builtin_vec_vsrv
 #endif
 
 /* Predicates.
index 4397cbcb005750e161ceef2ffce23a39b20bd180..d081bd1afbd1da8bbcd29e079c70e712252d018f 100644 (file)
    UNSPEC_STVLXL
    UNSPEC_STVRX
    UNSPEC_STVRXL
+   UNSPEC_VSLV
+   UNSPEC_VSRV
    UNSPEC_VMULWHUB
    UNSPEC_VMULWLUB
    UNSPEC_VMULWHSB
   "vslo %0,%1,%2"
   [(set_attr "type" "vecperm")])
 
+(define_insn "vslv"
+  [(set (match_operand:V16QI 0 "register_operand" "=v")
+       (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
+                      (match_operand:V16QI 2 "register_operand" "v")]
+         UNSPEC_VSLV))]
+  "TARGET_P9_VECTOR"
+  "vslv %0,%1,%2"
+  [(set_attr "type" "vecsimple")])
+
+(define_insn "vsrv"
+  [(set (match_operand:V16QI 0 "register_operand" "=v")
+       (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
+                      (match_operand:V16QI 2 "register_operand" "v")]
+         UNSPEC_VSRV))]
+  "TARGET_P9_VECTOR"
+  "vsrv %0,%1,%2"
+  [(set_attr "type" "vecsimple")])
+
 (define_insn "*altivec_vsl<VI_char>"
   [(set (match_operand:VI2 0 "register_operand" "=v")
         (ashift:VI2 (match_operand:VI2 1 "register_operand" "v")
index 177b8aef353080ba8dc43c34255f297629266353..35a2e130ef46546e19e9d5f9dfab99cc18ed7648 100644 (file)
@@ -1749,6 +1749,14 @@ BU_P8V_OVERLOAD_3 (VADDEUQM,     "vaddeuqm")
 BU_P8V_OVERLOAD_3 (VSUBECUQ,   "vsubecuq")
 BU_P8V_OVERLOAD_3 (VSUBEUQM,   "vsubeuqm")
 
+/* ISA 3.0 vector overloaded 2-argument functions. */
+BU_P9V_AV_2 (VSLV,             "vslv",                 CONST, vslv)
+BU_P9V_AV_2 (VSRV,             "vsrv",                 CONST, vsrv)
+
+/* ISA 3.0 vector overloaded 2-argument functions. */
+BU_P9V_OVERLOAD_2 (VSLV,       "vslv")
+BU_P9V_OVERLOAD_2 (VSRV,       "vsrv")
+
 \f
 /* 2 argument extended divide functions added in ISA 2.06.  */
 BU_P7_MISC_2 (DIVWE,           "divwe",        CONST,  dive_si)
index eb1539cf73a09278b81278da267255e638ad059e..79ac1158c76fc4719d0f57c61fd916476bba99ca 100644 (file)
@@ -4488,6 +4488,13 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
   { P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD,
     RS6000_BTI_unsigned_V16QI, 0, 0, 0 },
 
+  { P9V_BUILTIN_VEC_VSLV, P9V_BUILTIN_VSLV,
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
+    RS6000_BTI_unsigned_V16QI, 0 },
+  { P9V_BUILTIN_VEC_VSRV, P9V_BUILTIN_VSRV,
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
+    RS6000_BTI_unsigned_V16QI, 0 },
+
   /* Crypto builtins.  */
   { CRYPTO_BUILTIN_VPERMXOR, CRYPTO_BUILTIN_VPERMXOR_V16QI,
     RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
index 2d4f02888df310f4590396cf89eb626f0fea7c57..b2190d6d75afd00b1f6b22602c7a308e3141a2e2 100644 (file)
@@ -14686,8 +14686,8 @@ The @code{__builtin_divde}, @code{__builtin_divdeo},
 64-bit environment support ISA 2.06 or later.
 
 The following built-in functions are available for the PowerPC family
-of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}
-or @option{-mmodulo}):
+of processors, starting with ISA 3.0 or later (@option{-mcpu=power9})
+or with @option{-mmodulo}:
 @smallexample
 long long __builtin_darn (void);
 long long __builtin_darn_raw (void);
@@ -17341,6 +17341,40 @@ vector __int128_t vec_vprtybq (vector __int128_t);
 vector __uint128_t vec_vprtybd (vector __uint128_t);
 @end smallexample
 
+The following built-in vector functions are available for the PowerPC family
+of processors, starting with ISA 3.0 or later (@option{-mcpu=power9})
+or with @option{-mpower9-vector}:
+@smallexample
+__vector unsigned char
+vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
+__vector unsigned char
+vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
+@end smallexample
+
+The @code{vec_slv} and @code{vec_srv} functions operate on
+all of the bytes of their @code{src} and @code{shift_distance}
+arguments in parallel.  The behavior of the @code{vec_slv} is as if
+there existed a temporary array of 17 unsigned characters
+@code{slv_array} within which elements 0 through 15 are the same as
+the entries in the @code{src} array and element 16 equals 0.  The
+result returned from the @code{vec_slv} function is a
+@code{__vector} of 16 unsigned characters within which element
+@code{i} is computed using the C expression
+@code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
+shift_distance[i]))},
+with this resulting value coerced to the @code{unsigned char} type.
+The behavior of the @code{vec_srv} is as if
+there existed a temporary array of 17 unsigned characters
+@code{srv_array} within which element 0 equals zero and
+elements 1 through 16 equal the elements 0 through 15 of
+the @code{src} array.  The
+result returned from the @code{vec_srv} function is a
+@code{__vector} of 16 unsigned characters within which element
+@code{i} is computed using the C expression
+@code{0xff & (*((unsigned short *)(srv_array + i)) >>
+(0x07 & shift_distance[i]))},
+with this resulting value coerced to the @code{unsigned char} type.
+
 If the cryptographic instructions are enabled (@option{-mcrypto} or
 @option{-mcpu=power8}), the following builtins are enabled.
 
index b903f402834c6c98bd36e1a231c1a41b43098f9e..cb6e4871dd9da3667024b5d9fbc7ca65b0b55bff 100644 (file)
@@ -1,3 +1,10 @@
+2016-06-01  Kelvin Nilsen  <kelvin@gcc.gnu.org>
+
+       * gcc.target/powerpc/vslv-0.c: New test.
+       * gcc.target/powerpc/vslv-1.c: New test.
+       * gcc.target/powerpc/vsrv-0.c: New test.
+       * gcc.target/powerpc/vsrv-1.c: New test.
+
 2016-06-01  Nathan Sidwell  <nathan@acm.org>
 
        * c-c++-common/torture/pr57945.c: Add expected PTX error.
diff --git a/gcc/testsuite/gcc.target/powerpc/vslv-0.c b/gcc/testsuite/gcc.target/powerpc/vslv-0.c
new file mode 100644 (file)
index 0000000..1414be1
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-options "-mcpu=power9" } */
+
+#include <altivec.h>
+
+__vector unsigned char
+doCharShiftLeft (__vector unsigned char *p, __vector unsigned char *q)
+{
+  __vector unsigned char result, input, shift_distance;
+  result = __builtin_vec_vslv (input, shift_distance);
+  return result;
+}
+
+/* { dg-final { scan-assembler "vslv" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vslv-1.c b/gcc/testsuite/gcc.target/powerpc/vslv-1.c
new file mode 100644 (file)
index 0000000..293f6d4
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-options "-mcpu=power9" } */
+
+#include <altivec.h>
+
+__vector unsigned char
+doCharShiftLeft (__vector unsigned char *p, __vector unsigned char *q)
+{
+  __vector unsigned char result, input, shift_distance;
+  result = vec_slv (input, shift_distance);
+  return result;
+}
+
+/* { dg-final { scan-assembler "vslv" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vsrv-0.c b/gcc/testsuite/gcc.target/powerpc/vsrv-0.c
new file mode 100644 (file)
index 0000000..29e7716
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-options "-mcpu=power9" } */
+
+#include <altivec.h>
+
+__vector unsigned char
+doCharShiftLeft (__vector unsigned char *p, __vector unsigned char *q)
+{
+  __vector unsigned char result, input, shift_distance;
+  result = __builtin_vec_vsrv (input, shift_distance);
+  return result;
+}
+
+/* { dg-final { scan-assembler "vsrv" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vsrv-1.c b/gcc/testsuite/gcc.target/powerpc/vsrv-1.c
new file mode 100644 (file)
index 0000000..fd74322
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-options "-mcpu=power9" } */
+
+#include <altivec.h>
+
+__vector unsigned char
+doCharShiftLeft (__vector unsigned char *p, __vector unsigned char *q)
+{
+  __vector unsigned char result, input, shift_distance;
+  result = vec_srv (input, shift_distance);
+  return result;
+}
+
+/* { dg-final { scan-assembler "vsrv" } } */