+2016-06-13 Kelvin Nilsen <kelvin@gcc.gnu.org>
+
+ * config/rs6000/altivec.h (vec_absd): New macro for vector absolute
+ difference unsigned.
+ (vec_absdb): New macro for vector absolute difference unsigned
+ byte.
+ (vec_absdh): New macro for vector absolute difference unsigned
+ half-word.
+ (vec_absdw): New macro for vector absolute difference unsigned word.
+ * config/rs6000/altivec.md (UNSPEC_VADU): New value.
+ (vadu<mode>3): New insn.
+ (*p9_vadu<mode>3): New insn.
+ * config/rs6000/rs6000-builtin.def (vadub): New built-in
+ definition.
+ (vaduh): New built-in definition.
+ (vaduw): New built-in definition.
+ (vadu): New overloaded built-in definition.
+ (vadub): New overloaded built-in definition.
+ (vaduh): New overloaded built-in definition.
+ (vaduw): New overloaded built-in definition.
+ * config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Add
+ overloaded vector absolute difference unsigned functions.
+ * doc/extend.texi (PowerPC AltiVec Built-in Functions): Document
+ the ISA 3.0 vector absolute difference unsigned built-in functions.
+
2016-06-13 Eric Botcazou <ebotcazou@adacore.com>
* tree-ssa-sccvn.c (vn_reference_lookup_3): Use a uniform test and
#define vec_vprtybq __builtin_vec_vprtybq
#endif
+#define vec_absd __builtin_vec_vadu
+#define vec_absdb __builtin_vec_vadub
+#define vec_absdh __builtin_vec_vaduh
+#define vec_absdw __builtin_vec_vaduw
+
#define vec_slv __builtin_vec_vslv
#define vec_srv __builtin_vec_vsrv
#endif
UNSPEC_STVLXL
UNSPEC_STVRX
UNSPEC_STVRXL
+ UNSPEC_VADU
UNSPEC_VSLV
UNSPEC_VSRV
UNSPEC_VMULWHUB
[(set_attr "length" "4")
(set_attr "type" "vecsimple")])
+;; Vector absolute difference unsigned
+(define_expand "vadu<mode>3"
+ [(set (match_operand:VI 0 "register_operand")
+ (unspec:VI [(match_operand:VI 1 "register_operand")
+ (match_operand:VI 2 "register_operand")]
+ UNSPEC_VADU))]
+ "TARGET_P9_VECTOR")
+
+;; Vector absolute difference unsigned
+(define_insn "*p9_vadu<mode>3"
+ [(set (match_operand:VI 0 "register_operand" "=v")
+ (unspec:VI [(match_operand:VI 1 "register_operand" "v")
+ (match_operand:VI 2 "register_operand" "v")]
+ UNSPEC_VADU))]
+ "TARGET_P9_VECTOR"
+ "vabsdu<wd> %0,%1,%2"
+ [(set_attr "type" "vecsimple")])
+
;; Vector count trailing zeros
(define_insn "*p9v_ctz<mode>2"
[(set (match_operand:VI2 0 "register_operand" "=v")
BU_P9V_OVERLOAD_2 (VSLV, "vslv")
BU_P9V_OVERLOAD_2 (VSRV, "vsrv")
+/* 2 argument vector functions added in ISA 3.0 (power9). */
+BU_P9V_AV_2 (VADUB, "vadub", CONST, vaduv16qi3)
+BU_P9V_AV_2 (VADUH, "vaduh", CONST, vaduv8hi3)
+BU_P9V_AV_2 (VADUW, "vaduw", CONST, vaduv4si3)
+
+/* ISA 3.0 vector overloaded 2 argument functions. */
+BU_P9V_OVERLOAD_2 (VADU, "vadu")
+BU_P9V_OVERLOAD_2 (VADUB, "vadub")
+BU_P9V_OVERLOAD_2 (VADUH, "vaduh")
+BU_P9V_OVERLOAD_2 (VADUW, "vaduw")
+
\f
/* 2 argument extended divide functions added in ISA 2.06. */
BU_P7_MISC_2 (DIVWE, "divwe", CONST, dive_si)
{ P9V_BUILTIN_VEC_VCTZD, P9V_BUILTIN_VCTZD,
RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0, 0 },
+ { P9V_BUILTIN_VEC_VADU, P9V_BUILTIN_VADUB,
+ RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
+ RS6000_BTI_unsigned_V16QI, 0 },
+ { P9V_BUILTIN_VEC_VADU, P9V_BUILTIN_VADUH,
+ RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
+ RS6000_BTI_unsigned_V8HI, 0 },
+ { P9V_BUILTIN_VEC_VADU, P9V_BUILTIN_VADUW,
+ RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
+ RS6000_BTI_unsigned_V4SI, 0 },
+
+ { P9V_BUILTIN_VEC_VADUB, P9V_BUILTIN_VADUB,
+ RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
+ RS6000_BTI_unsigned_V16QI, 0 },
+
+ { P9V_BUILTIN_VEC_VADUH, P9V_BUILTIN_VADUH,
+ RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
+ RS6000_BTI_unsigned_V8HI, 0 },
+
+ { P9V_BUILTIN_VEC_VADUW, P9V_BUILTIN_VADUW,
+ RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
+ RS6000_BTI_unsigned_V4SI, 0 },
+
{ P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD,
RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0, 0 },
{ P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD,
(0x07 & shift_distance[i]))},
with this resulting value coerced to the @code{unsigned char} type.
+The following built-in 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_absd (__vector unsigned char arg1, __vector unsigned char arg2);
+__vector unsigned short
+vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
+__vector unsigned int
+vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
+
+__vector unsigned char
+vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
+__vector unsigned short
+vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
+__vector unsigned int
+vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
+@end smallexample
+
+The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
+@code{vec_absdw} built-in functions each computes the absolute
+differences of the pairs of vector elements supplied in its two vector
+arguments, placing the absolute differences into the corresponding
+elements of the vector result.
+
If the cryptographic instructions are enabled (@option{-mcrypto} or
@option{-mcpu=power8}), the following builtins are enabled.
+2016-06-13 Kelvin Nilsen <kelvin@gcc.gnu.org>
+
+ * gcc.target/powerpc/vadsdu-0.c: New test.
+ * gcc.target/powerpc/vadsdu-1.c: New test.
+ * gcc.target/powerpc/vadsdu-2.c: New test.
+ * gcc.target/powerpc/vadsdu-3.c: New test.
+ * gcc.target/powerpc/vadsdu-4.c: New test.
+ * gcc.target/powerpc/vadsdu-5.c: New test.
+ * gcc.target/powerpc/vadsdub-1.c: New test.
+ * gcc.target/powerpc/vadsdub-2.c: New test.
+ * gcc.target/powerpc/vadsduh-1.c: New test.
+ * gcc.target/powerpc/vadsduh-2.c: New test.
+ * gcc.target/powerpc/vadsduw-1.c: New test.
+ * gcc.target/powerpc/vadsduw-2.c: New test.
+
2016-06-13 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/c99-init-2.c (c): Update expected error message.
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned int
+doAbsoluteDifferenceUnsignedInt (__vector unsigned int *p,
+ __vector unsigned int *q)
+{
+ __vector unsigned int source_1, source_2;
+ __vector unsigned int result;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ result = __builtin_vec_vadu (source_1, source_2);
+ return result;
+}
+
+/* { dg-final { scan-assembler "vabsduw" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned int
+doAbsoluteDifferenceUnsignedIntMacro (__vector unsigned int *p,
+ __vector unsigned int *q)
+{
+ __vector unsigned int result, source_1, source_2;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ result = vec_absd (source_1, source_2);
+ return result;
+}
+
+/* { dg-final { scan-assembler "vabsduw" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned short
+doAbsoluteDifferenceUnsignedShort (__vector unsigned short *p,
+ __vector unsigned short *q)
+{
+ __vector unsigned short source_1, source_2;
+ __vector unsigned short result;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ result = __builtin_vec_vadu (source_1, source_2);
+ return result;
+}
+
+/* { dg-final { scan-assembler "vabsduh" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned short
+doAbsoluteDifferenceUnsignedShortMacro (__vector unsigned short *p,
+ __vector unsigned short *q)
+{
+ __vector unsigned short result, source_1, source_2;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ result = vec_absd (source_1, source_2);
+ return result;
+}
+
+/* { dg-final { scan-assembler "vabsduh" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned char
+doAbsoluteDifferenceUnsignedChar (__vector unsigned char *p,
+ __vector unsigned char *q)
+{
+ __vector unsigned char source_1, source_2;
+ __vector unsigned char result;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ result = __builtin_vec_vadu (source_1, source_2);
+ return result;
+}
+
+/* { dg-final { scan-assembler "vabsdub" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned char
+doAbsoluteDifferenceUnsignedCharMacro (__vector unsigned char *p,
+ __vector unsigned char *q)
+{
+ __vector unsigned char result, source_1, source_2;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ result = vec_absd (source_1, source_2);
+ return result;
+}
+
+/* { dg-final { scan-assembler "vabsdub" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned char
+doAbsoluteDifferenceUnsigned (__vector unsigned char *p,
+ __vector unsigned char *q)
+{
+ __vector unsigned char source_1, source_2;
+ __vector unsigned char uc_result;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ uc_result = __builtin_vec_vadub (source_1, source_2);
+ return uc_result;
+}
+
+/* { dg-final { scan-assembler "vabsdub" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned char
+doAbsoluteDifferenceUnsigned (__vector unsigned char *p,
+ __vector unsigned char *q)
+{
+ __vector unsigned char source_1, source_2;
+ __vector unsigned char uc_result;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ uc_result = __builtin_vec_vadub (source_1, source_2);
+ return uc_result;
+}
+
+/* { dg-final { scan-assembler "vabsdub" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned short
+doAbsoluteDifferenceUnsigned (__vector unsigned short *p,
+ __vector unsigned short *q)
+{
+ __vector unsigned short source_1, source_2;
+ __vector unsigned short us_result;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ us_result = __builtin_vec_vaduh (source_1, source_2);
+ return us_result;
+}
+
+/* { dg-final { scan-assembler "vabsduh" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned short
+doAbsoluteDifferenceUnsignedMacro (__vector unsigned short *p,
+ __vector unsigned short *q)
+{
+ __vector unsigned short result, source_1, source_2;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ result = vec_absdh (source_1, source_2);
+ return result;
+}
+
+/* { dg-final { scan-assembler "vabsduh" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned int
+doAbsoluteDifferenceUnsigned (__vector unsigned int *p,
+ __vector unsigned int *q)
+{
+ __vector unsigned int source_1, source_2;
+ __vector unsigned int ui_result;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ ui_result = __builtin_vec_vaduw (source_1, source_2);
+ return ui_result;
+}
+
+/* { dg-final { scan-assembler "vabsduw" } } */
--- /dev/null
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target p9vector_hw } */
+/* { dg-options "-mcpu=power9" } */
+
+/* This test should succeed on both 32- and 64-bit configurations. */
+#include <altivec.h>
+
+__vector unsigned int
+doAbsoluteDifferenceUnsignedMacro (__vector unsigned int *p,
+ __vector unsigned int *q)
+{
+ __vector unsigned int result, source_1, source_2;
+
+ source_1 = *p;
+ source_2 = *q;
+
+ result = vec_absdw (source_1, source_2);
+ return result;
+}
+
+/* { dg-final { scan-assembler "vabsduw" } } */