aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/torture
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/c-c++-common/torture')
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-alias-1.c35
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-add.c55
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c55
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-div.c47
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-mul.c55
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c55
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul-minus-one.c63
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul-one.c63
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul.c55
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-sub.c55
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign.h80
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/pr42834.c23
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/pr46137.c18
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/pr53505.c42
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/pr57945.c11
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/pr58794-1.c29
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/pr58794-2.c21
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/pr60026.c28
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-compare-1.c124
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-compare-2.c29
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift.c49
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift1.c18
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift2.c60
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-1.c61
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-2.c69
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c26
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-16.inc81
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-2.inc38
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-4.inc39
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-8.inc101
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-main.inc26
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v16hi.c5
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v16qi.c5
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2df.c15
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2di.c15
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2sf.c21
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2si.c18
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4df.c19
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4di.c19
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4hi.c15
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4sf.c25
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4si.c22
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8hi.c23
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8qi.c23
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8si.c30
45 files changed, 1766 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-alias-1.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-alias-1.c
new file mode 100644
index 000000000..cdf832d63
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-alias-1.c
@@ -0,0 +1,35 @@
+/* Accesses to complex numbers were sometimes marked as scalar and
+ sometimes as struct accesses. */
+/* { dg-do run } */
+/* { dg-options "-std=c99" { target c } } */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void abort (void);
+#ifdef __cplusplus
+}
+#endif
+static double _Complex *fp_cxd(double _Complex *cx) {
+ return cx;
+}
+
+int main( ) {
+ double _Complex cx = 4.0 + 3.0*(__extension__ 1.0iF);
+ double _Complex cx43 = 4.0 + 3.0*(__extension__ 1.0iF);
+ double _Complex cx11 = 1.0 + 1.0*(__extension__ 1.0iF);
+
+ *fp_cxd(&cx) *= cx11;
+ *fp_cxd(&cx) /= cx11;
+
+ double r_cx = __real__(cx);
+ double i_cx = __imag__(cx);
+ double r_cx43 = __real__(cx43);
+ double i_cx43 = __imag__(cx43);
+
+ if( (r_cx == r_cx43) && (i_cx == i_cx43) ) {
+ return 0;
+ } else {
+ abort ();
+ }
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-add.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-add.c
new file mode 100644
index 000000000..bcaf8bba9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-add.c
@@ -0,0 +1,55 @@
+/* Test complex arithmetic with signed zeros. Pure complex
+ addition. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_ADD(TYPE, COPY, ZERO, ZEROI) \
+ do { \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, +, +, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, +, +, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, +, -, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, +, -, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, -, +, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, -, +, -, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, -, -, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, -, -, -, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, +, +, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, +, +, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, +, -, +, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, +, -, -, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, -, +, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, -, +, -, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, -, -, +, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, -, -, -, -, -); \
+ } while (0)
+
+void
+check_add_float (void)
+{
+#ifndef __SPU__
+ CHECK_ADD (float, __builtin_copysignf, 0.0f, 0.0if);
+#endif
+}
+
+void
+check_add_double (void)
+{
+ CHECK_ADD (double, __builtin_copysign, 0.0, 0.0i);
+}
+
+void
+check_add_long_double (void)
+{
+ CHECK_ADD (long double, __builtin_copysignl, 0.0l, 0.0il);
+}
+
+int
+main (void)
+{
+ check_add_float ();
+ check_add_double ();
+ check_add_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c
new file mode 100644
index 000000000..caea562e8
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c
@@ -0,0 +1,55 @@
+/* Test complex arithmetic with signed zeros. Mixed real/complex
+ addition. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_ADD(TYPE, COPY, ZERO, ZEROI) \
+ do { \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, +, +, +, +, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, +, +, -, +, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, +, -, +, +, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, +, -, -, +, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, -, +, +, +, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, -, +, -, +, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, -, -, +, -, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, -, -, -, -, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, +, +, +, ZERO, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, +, +, -, ZERO, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, +, -, +, ZERO, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, +, -, -, ZERO, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, -, +, +, ZERO, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, -, +, -, ZERO, -, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, -, -, +, ZERO, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, -, -, -, ZERO, -, -); \
+ } while (0)
+
+void
+check_add_float (void)
+{
+#ifndef __SPU__
+ CHECK_ADD (float, __builtin_copysignf, 0.0f, 0.0if);
+#endif
+}
+
+void
+check_add_double (void)
+{
+ CHECK_ADD (double, __builtin_copysign, 0.0, 0.0i);
+}
+
+void
+check_add_long_double (void)
+{
+ CHECK_ADD (long double, __builtin_copysignl, 0.0l, 0.0il);
+}
+
+int
+main (void)
+{
+ check_add_float ();
+ check_add_double ();
+ check_add_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-div.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-div.c
new file mode 100644
index 000000000..269d5ec42
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-div.c
@@ -0,0 +1,47 @@
+/* Test complex arithmetic with signed zeros. Mixed real/complex
+ division. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_DIV(TYPE, COPY, ZERO, ZEROI, ONE) \
+ do { \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, +, +, +, ONE, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, +, +, -, ONE, -, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, +, -, +, ONE, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, +, -, -, ONE, -, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, -, +, +, ONE, -, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, -, +, -, ONE, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, -, -, +, ONE, -, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, -, -, -, ONE, +, +); \
+ } while (0)
+
+void
+check_div_float (void)
+{
+#ifndef __SPU__
+ CHECK_DIV (float, __builtin_copysignf, 0.0f, 0.0if, 1.0f);
+#endif
+}
+
+void
+check_div_double (void)
+{
+ CHECK_DIV (double, __builtin_copysign, 0.0, 0.0i, 1.0);
+}
+
+void
+check_div_long_double (void)
+{
+ CHECK_DIV (long double, __builtin_copysignl, 0.0l, 0.0il, 1.0l);
+}
+
+int
+main (void)
+{
+ check_div_float ();
+ check_div_double ();
+ check_div_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-mul.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-mul.c
new file mode 100644
index 000000000..e79db6d45
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-mul.c
@@ -0,0 +1,55 @@
+/* Test complex arithmetic with signed zeros. Mixed real/complex
+ multiplication. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_MUL(TYPE, COPY, ZERO, ZEROI) \
+ do { \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, +, +, +, +, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, +, +, -, +, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, +, -, +, -, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, +, -, -, -, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, -, +, +, -, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, -, +, -, -, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, -, -, +, +, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, -, -, -, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, +, +, +, ZERO, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, +, +, -, ZERO, -, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, +, -, +, ZERO, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, +, -, -, ZERO, -, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, -, +, +, ZERO, -, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, -, +, -, ZERO, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, -, -, +, ZERO, -, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, -, -, -, ZERO, +, +); \
+ } while (0)
+
+void
+check_mul_float (void)
+{
+#ifndef __SPU__
+ CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if);
+#endif
+}
+
+void
+check_mul_double (void)
+{
+ CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i);
+}
+
+void
+check_mul_long_double (void)
+{
+ CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il);
+}
+
+int
+main (void)
+{
+ check_mul_float ();
+ check_mul_double ();
+ check_mul_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c
new file mode 100644
index 000000000..d9e083cfd
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c
@@ -0,0 +1,55 @@
+/* Test complex arithmetic with signed zeros. Mixed real/complex
+ subtraction. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_SUB(TYPE, COPY, ZERO, ZEROI) \
+ do { \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, +, +, +, +, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, +, +, -, +, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, +, -, +, +, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, +, -, -, +, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, -, +, +, -, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, -, +, -, -, +); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, -, -, +, +, -); \
+ CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, -, -, -, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, +, +, +, ZERO, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, +, +, -, ZERO, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, +, -, +, ZERO, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, +, -, -, ZERO, +, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, -, +, +, ZERO, -, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, -, +, -, ZERO, +, +); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, -, -, +, ZERO, -, -); \
+ CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, -, -, -, ZERO, +, -); \
+ } while (0)
+
+void
+check_sub_float (void)
+{
+#ifndef __SPU__
+ CHECK_SUB (float, __builtin_copysignf, 0.0f, 0.0if);
+#endif
+}
+
+void
+check_sub_double (void)
+{
+ CHECK_SUB (double, __builtin_copysign, 0.0, 0.0i);
+}
+
+void
+check_sub_long_double (void)
+{
+ CHECK_SUB (long double, __builtin_copysignl, 0.0l, 0.0il);
+}
+
+int
+main (void)
+{
+ check_sub_float ();
+ check_sub_double ();
+ check_sub_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul-minus-one.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul-minus-one.c
new file mode 100644
index 000000000..d20b5e6c8
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul-minus-one.c
@@ -0,0 +1,63 @@
+/* Test complex arithmetic with signed zeros. Pure complex
+ multiplication with -1.0 + 0.0i. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_MUL_INT(TYPE, COPY, ZERO, ZEROI, ONE, S1, S2, SR, SI) \
+ do { \
+ _Complex TYPE a1, b1, c1; \
+ volatile _Complex TYPE a2, b2, c2; \
+ a1 = ENCODE(ZERO, ZEROI, S1, S2); \
+ CHECK_RES (a1, COPY, S1, S2); \
+ b1 = -ONE + ZEROI; \
+ c1 = a1 * b1; \
+ CHECK_RES (c1, COPY, SR, SI); \
+ c1 = a1 * (-ONE + ZEROI); \
+ CHECK_RES (c1, COPY, SR, SI); \
+ a2 = ENCODE(ZERO, ZEROI, S1, S2); \
+ CHECK_RES (a2, COPY, S1, S2); \
+ b2 = -ONE + ZEROI; \
+ c2 = a2 * b2; \
+ CHECK_RES (c2, COPY, SR, SI); \
+ c2 = a2 * (-ONE + ZEROI); \
+ CHECK_RES (c2, COPY, SR, SI); \
+ } while (0)
+
+#define CHECK_MUL(TYPE, COPY, ZERO, ZEROI, ONE) \
+ do { \
+ CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, +, -, +); \
+ CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, -, +, +); \
+ CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, +, +, -); \
+ CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, -, +, +); \
+ } while (0)
+
+void
+check_mul_float (void)
+{
+#ifndef __SPU__
+ CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if, 1.0f);
+#endif
+}
+
+void
+check_mul_double (void)
+{
+ CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i, 1.0);
+}
+
+void
+check_mul_long_double (void)
+{
+ CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il, 1.0l);
+}
+
+int
+main (void)
+{
+ check_mul_float ();
+ check_mul_double ();
+ check_mul_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul-one.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul-one.c
new file mode 100644
index 000000000..ad02a2cd6
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul-one.c
@@ -0,0 +1,63 @@
+/* Test complex arithmetic with signed zeros. Pure complex
+ multiplication with 1.0 + 0.0i. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_MUL_INT(TYPE, COPY, ZERO, ZEROI, ONE, S1, S2, SR, SI) \
+ do { \
+ _Complex TYPE a1, b1, c1; \
+ volatile _Complex TYPE a2, b2, c2; \
+ a1 = ENCODE(ZERO, ZEROI, S1, S2); \
+ CHECK_RES (a1, COPY, S1, S2); \
+ b1 = ONE + ZEROI; \
+ c1 = a1 * b1; \
+ CHECK_RES (c1, COPY, SR, SI); \
+ c1 = a1 * (ONE + ZEROI); \
+ CHECK_RES (c1, COPY, SR, SI); \
+ a2 = ENCODE(ZERO, ZEROI, S1, S2); \
+ CHECK_RES (a2, COPY, S1, S2); \
+ b2 = ONE + ZEROI; \
+ c2 = a2 * b2; \
+ CHECK_RES (c2, COPY, SR, SI); \
+ c2 = a2 * (ONE + ZEROI); \
+ CHECK_RES (c2, COPY, SR, SI); \
+ } while (0)
+
+#define CHECK_MUL(TYPE, COPY, ZERO, ZEROI, ONE) \
+ do { \
+ CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, +, +, +); \
+ CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, -, +, +); \
+ CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, +, -, +); \
+ CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, -, +, -); \
+ } while (0)
+
+void
+check_mul_float (void)
+{
+#ifndef __SPU__
+ CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if, 1.0f);
+#endif
+}
+
+void
+check_mul_double (void)
+{
+ CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i, 1.0);
+}
+
+void
+check_mul_long_double (void)
+{
+ CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il, 1.0l);
+}
+
+int
+main (void)
+{
+ check_mul_float ();
+ check_mul_double ();
+ check_mul_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul.c
new file mode 100644
index 000000000..a3274d2ea
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-mul.c
@@ -0,0 +1,55 @@
+/* Test complex arithmetic with signed zeros. Pure complex
+ multiplication. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_MUL(TYPE, COPY, ZERO, ZEROI) \
+ do { \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, +, +, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, +, +, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, +, -, +, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, +, -, -, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, -, +, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, -, +, -, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, -, -, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, -, -, -, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, +, +, +, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, +, +, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, +, -, +, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, +, -, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, -, +, +, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, -, +, -, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, -, -, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, -, -, -, +, +); \
+ } while (0)
+
+void
+check_mul_float (void)
+{
+#ifndef __SPU__
+ CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if);
+#endif
+}
+
+void
+check_mul_double (void)
+{
+ CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i);
+}
+
+void
+check_mul_long_double (void)
+{
+ CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il);
+}
+
+int
+main (void)
+{
+ check_mul_float ();
+ check_mul_double ();
+ check_mul_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-sub.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-sub.c
new file mode 100644
index 000000000..0a4e3029e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign-sub.c
@@ -0,0 +1,55 @@
+/* Test complex arithmetic with signed zeros. Pure complex
+ subtraction. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" { target c } } */
+
+#include "complex-sign.h"
+
+#define CHECK_SUB(TYPE, COPY, ZERO, ZEROI) \
+ do { \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, +, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, +, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, -, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, -, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, +, +, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, +, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, -, +, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, -, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, +, +, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, +, -, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, -, +, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, -, -, +, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, +, +, -, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, +, -, -, +); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, -, +, +, -); \
+ CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, -, -, +, +); \
+ } while (0)
+
+void
+check_sub_float (void)
+{
+#ifndef __SPU__
+ CHECK_SUB (float, __builtin_copysignf, 0.0f, 0.0if);
+#endif
+}
+
+void
+check_sub_double (void)
+{
+ CHECK_SUB (double, __builtin_copysign, 0.0, 0.0i);
+}
+
+void
+check_sub_long_double (void)
+{
+ CHECK_SUB (long double, __builtin_copysignl, 0.0l, 0.0il);
+}
+
+int
+main (void)
+{
+ check_sub_float ();
+ check_sub_double ();
+ check_sub_long_double ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign.h b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign.h
new file mode 100644
index 000000000..96261101c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/complex-sign.h
@@ -0,0 +1,80 @@
+/* Common header for complex arithmetic sign tests. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void abort (void);
+extern void exit (int);
+#ifdef __cplusplus
+}
+#endif
+
+#define CHECK_RES(VALUE, COPY, SIGN_REAL, SIGN_IMAG) \
+ do { \
+ if ((VALUE) != 0 \
+ || COPY (1.0, __real__ (VALUE)) != SIGN_REAL 1.0 \
+ || COPY (1.0, __imag__ (VALUE)) != SIGN_IMAG 1.0) \
+ abort (); \
+ } while (0)
+
+/* This definition is intended to work with or without imaginary
+ types, as long as mixed real/complex arithmetic is handled
+ correctly. */
+#define ENCODE(ZERO, ZEROI, SA, SB) \
+ (SA 1 == 1 \
+ ? SB 1 == 1 ? ZERO + ZEROI : ZERO - ZEROI \
+ : SB 1 == 1 ? -(ZERO - ZEROI) : -(ZERO + ZEROI))
+
+#define CHECK_ARITH(TYPE, COPY, ZERO, ZEROI, OP, S1, S2, S3, S4, SR, SI) \
+ do { \
+ _Complex TYPE a1, b1, c1; \
+ volatile _Complex TYPE a2, b2, c2; \
+ a1 = ENCODE(ZERO, ZEROI, S1, S2); \
+ CHECK_RES (a1, COPY, S1, S2); \
+ b1 = ENCODE(ZERO, ZEROI, S3, S4); \
+ CHECK_RES (b1, COPY, S3, S4); \
+ c1 = a1 OP b1; \
+ CHECK_RES (c1, COPY, SR, SI); \
+ a2 = ENCODE(ZERO, ZEROI, S1, S2); \
+ CHECK_RES (a2, COPY, S1, S2); \
+ b2 = ENCODE(ZERO, ZEROI, S3, S4); \
+ CHECK_RES (b2, COPY, S3, S4); \
+ c2 = a2 OP b2; \
+ CHECK_RES (c2, COPY, SR, SI); \
+ } while (0)
+
+#define CHECK_ARITH_RC(TYPE, COPY, ZERO, ZEROI, OP, S1, S3, S4, SR, SI) \
+ do { \
+ TYPE a1; \
+ _Complex TYPE b1, c1; \
+ volatile TYPE a2; \
+ volatile _Complex TYPE b2, c2; \
+ a1 = S1 ZERO; \
+ b1 = ENCODE(ZERO, ZEROI, S3, S4); \
+ CHECK_RES (b1, COPY, S3, S4); \
+ c1 = a1 OP b1; \
+ CHECK_RES (c1, COPY, SR, SI); \
+ a2 = S1 ZERO; \
+ b2 = ENCODE(ZERO, ZEROI, S3, S4); \
+ CHECK_RES (b2, COPY, S3, S4); \
+ c2 = a2 OP b2; \
+ CHECK_RES (c2, COPY, SR, SI); \
+ } while (0)
+
+#define CHECK_ARITH_CR(TYPE, COPY, ZERO, ZEROI, OP, S1, S2, S3, V3, SR, SI) \
+ do { \
+ _Complex TYPE a1, c1; \
+ TYPE b1; \
+ volatile _Complex TYPE a2, c2; \
+ volatile TYPE b2; \
+ a1 = ENCODE(ZERO, ZEROI, S1, S2); \
+ CHECK_RES (a1, COPY, S1, S2); \
+ b1 = S3 V3; \
+ c1 = a1 OP b1; \
+ CHECK_RES (c1, COPY, SR, SI); \
+ a2 = ENCODE(ZERO, ZEROI, S1, S2); \
+ CHECK_RES (a2, COPY, S1, S2); \
+ b2 = S3 V3; \
+ c2 = a2 OP b2; \
+ CHECK_RES (c2, COPY, SR, SI); \
+ } while (0)
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr42834.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr42834.c
new file mode 100644
index 000000000..a1ba49e46
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr42834.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+
+void __attribute__((noinline,noclone))
+foo(int *p, float *q) { __asm__ volatile ("" : : : "memory"); }
+
+int main()
+{
+ if (sizeof (int) == sizeof (float))
+ {
+ int i;
+ float f;
+ int *p;
+ /* Prevent i and f from being rewritten into SSA form. */
+ foo (&i, &f);
+ i = 0;
+ f = 1.0;
+ p = (int *)&f;
+ __builtin_memcpy (&i, p, 4);
+ if (*(float *)&i != 1.0)
+ __builtin_abort ();
+ }
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr46137.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr46137.c
new file mode 100644
index 000000000..3e44ff6b7
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr46137.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+struct X { };
+
+static inline void *
+bar (void *dst, void *src)
+{
+ return __builtin___memcpy_chk (dst, src, sizeof (struct X),
+ __builtin_object_size (dst, 0));
+}
+
+struct X
+foo (struct X *x)
+{
+ struct X any;
+ bar (&any, x);
+ return any;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr53505.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr53505.c
new file mode 100644
index 000000000..922711025
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr53505.c
@@ -0,0 +1,42 @@
+/* PR tree-optimization/53505 */
+/* { dg-do run } */
+
+#include <stdbool.h>
+
+struct A
+{
+ unsigned int a;
+ unsigned char c1, c2;
+ bool b1 : 1;
+ bool b2 : 1;
+ bool b3 : 1;
+};
+
+void
+foo (const struct A *x, int y)
+{
+ int s = 0, i;
+ for (i = 0; i < y; ++i)
+ {
+ const struct A a = x[i];
+ s += a.b1 ? 1 : 0;
+ }
+ if (s != 0)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ struct A x[100];
+ int i;
+ __builtin_memset (x, -1, sizeof (x));
+ for (i = 0; i < 100; i++)
+ {
+ x[i].b1 = false;
+ x[i].b2 = false;
+ x[i].b3 = false;
+ }
+ foo (x, 100);
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr57945.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr57945.c
new file mode 100644
index 000000000..0803e8ff2
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr57945.c
@@ -0,0 +1,11 @@
+/* PR c++/57945 */
+/* { dg-do compile } */
+
+extern int j;
+static int i __attribute__((weakref("j")));
+
+int
+foo (void)
+{
+ return &i ? i : 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr58794-1.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr58794-1.c
new file mode 100644
index 000000000..175629fec
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr58794-1.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+
+struct S0
+{
+ int f;
+};
+
+struct S1
+{
+ struct S0 f1;
+ volatile int f2;
+};
+
+struct S2
+{
+ struct S1 g;
+} a, b;
+
+static int *c[1][2] = {{0, (int *)&a.g.f2}};
+static int d;
+
+int
+main ()
+{
+ for (d = 0; d < 1; d++)
+ for (b.g.f1.f = 0; b.g.f1.f < 1; b.g.f1.f++)
+ *c[b.g.f1.f][d + 1] = 0;
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr58794-2.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr58794-2.c
new file mode 100644
index 000000000..767798806
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr58794-2.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+struct S
+{
+ volatile int f;
+} a;
+
+unsigned int b;
+
+static int *c[1][2] = {{0, (int *)&a.f}};
+static unsigned int d;
+
+int
+main ()
+{
+ for (; d < 1; d++)
+ for (; b < 1; b++)
+ *c[b][d + 1] = 0;
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr60026.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr60026.c
new file mode 100644
index 000000000..1cc5f55a4
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/pr60026.c
@@ -0,0 +1,28 @@
+/* PR ipa/60026 */
+/* { dg-do compile } */
+
+struct S { int f; } a;
+
+__attribute__((optimize (0)))
+struct S foo (int x, struct S y)
+{
+ int b = y.f;
+ return a;
+}
+
+void
+bar ()
+{
+ while (a.f)
+ {
+ struct S c = {0};
+ foo (0, c);
+ }
+}
+
+int
+main ()
+{
+ bar ();
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-compare-1.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-compare-1.c
new file mode 100644
index 000000000..4cdfcf718
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-compare-1.c
@@ -0,0 +1,124 @@
+/* { dg-do run } */
+#define vector(elcount, type) \
+__attribute__((vector_size((elcount)*sizeof(type)))) type
+
+#define check_compare(count, res, i0, i1, op, fmt) \
+do { \
+ int __i; \
+ for (__i = 0; __i < count; __i ++) { \
+ if ((res)[__i] != ((i0)[__i] op (i1)[__i] ? -1 : 0)) \
+ { \
+ __builtin_printf ("%i != ((" fmt " " #op " " fmt " ? -1 : 0) ", \
+ (res)[__i], (i0)[__i], (i1)[__i]); \
+ __builtin_abort (); \
+ } \
+ } \
+} while (0)
+
+#define test(count, v0, v1, res, fmt); \
+do { \
+ res = (v0 > v1); \
+ check_compare (count, res, v0, v1, >, fmt); \
+ res = (v0 < v1); \
+ check_compare (count, res, v0, v1, <, fmt); \
+ res = (v0 >= v1); \
+ check_compare (count, res, v0, v1, >=, fmt); \
+ res = (v0 <= v1); \
+ check_compare (count, res, v0, v1, <=, fmt); \
+ res = (v0 == v1); \
+ check_compare (count, res, v0, v1, ==, fmt); \
+ res = (v0 != v1); \
+ check_compare (count, res, v0, v1, !=, fmt); \
+} while (0)
+
+
+int main (int argc, char *argv[]) {
+#define INT int
+ vector (4, INT) i0;
+ vector (4, INT) i1;
+ vector (4, int) ires;
+ int i;
+
+ i0 = (vector (4, INT)){(INT)argc, 1, 2, 10};
+ i1 = (vector (4, INT)){0, 3, 2, (INT)-23};
+ test (4, i0, i1, ires, "%i");
+#undef INT
+
+#define INT unsigned int
+ vector (4, int) ures;
+ vector (4, INT) u0;
+ vector (4, INT) u1;
+
+ u0 = (vector (4, INT)){(INT)argc, 1, 2, 10};
+ u1 = (vector (4, INT)){0, 3, 2, (INT)-23};
+ test (4, u0, u1, ures, "%u");
+#undef INT
+
+
+#define SHORT short
+ vector (8, SHORT) s0;
+ vector (8, SHORT) s1;
+ vector (8, short) sres;
+
+ s0 = (vector (8, SHORT)){(SHORT)argc, 1, 2, 10, 6, 87, (SHORT)-5, 2};
+ s1 = (vector (8, SHORT)){0, 3, 2, (SHORT)-23, 12, 10, (SHORT)-2, 0};
+ test (8, s0, s1, sres, "%i");
+#undef SHORT
+
+#define SHORT unsigned short
+ vector (8, SHORT) us0;
+ vector (8, SHORT) us1;
+ vector (8, short) usres;
+
+ us0 = (vector (8, SHORT)){(SHORT)argc, 1, 2, 10, 6, 87, (SHORT)-5, 2};
+ us1 = (vector (8, SHORT)){0, 3, 2, (SHORT)-23, 12, 10, (SHORT)-2, 0};
+ test (8, us0, us1, usres, "%u");
+#undef SHORT
+
+#define CHAR signed char
+ vector (16, CHAR) c0;
+ vector (16, CHAR) c1;
+ vector (16, signed char) cres;
+
+ c0 = (vector (16, CHAR)){(CHAR)argc, 1, 2, 10, 6, 87, (CHAR)-5, 2, \
+ (CHAR)argc, 1, 2, 10, 6, 87, (CHAR)-5, 2 };
+
+ c1 = (vector (16, CHAR)){0, 3, 2, (CHAR)-23, 12, 10, (CHAR)-2, 0, \
+ 0, 3, 2, (CHAR)-23, 12, 10, (CHAR)-2, 0};
+ test (16, c0, c1, cres, "%i");
+#undef CHAR
+
+#define CHAR unsigned char
+ vector (16, CHAR) uc0;
+ vector (16, CHAR) uc1;
+ vector (16, signed char) ucres;
+
+ uc0 = (vector (16, CHAR)){(CHAR)argc, 1, 2, 10, 6, 87, (CHAR)-5, 2, \
+ (CHAR)argc, 1, 2, 10, 6, 87, (CHAR)-5, 2 };
+
+ uc1 = (vector (16, CHAR)){0, 3, 2, (CHAR)-23, 12, 10, (CHAR)-2, 0, \
+ 0, 3, 2, (CHAR)-23, 12, 10, (CHAR)-2, 0};
+ test (16, uc0, uc1, ucres, "%u");
+#undef CHAR
+/* Float comparison. */
+ vector (4, float) f0;
+ vector (4, float) f1;
+ __typeof (f0 == f1) ifres;
+
+ f0 = (vector (4, float)){(float)argc, 1., 2., 10.};
+ f1 = (vector (4, float)){0., 3., 2., (float)-23};
+ test (4, f0, f1, ifres, "%f");
+
+/* Double comparison. */
+ vector (2, double) d0;
+ vector (2, double) d1;
+ __typeof (d0 == d1) idres;
+
+ d0 = (vector (2, double)){(double)argc, 10.};
+ d1 = (vector (2, double)){0., (double)-23};
+ test (2, d0, d1, idres, "%f");
+
+
+ return 0;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-compare-2.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-compare-2.c
new file mode 100644
index 000000000..628a69903
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-compare-2.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-Wno-psabi -w" } */
+#define vector(elcount, type) \
+__attribute__((vector_size((elcount)*sizeof(type)))) type
+
+/* Check that constant folding in
+ these simple cases works. */
+vector (4, int)
+foo (vector (4, int) x)
+{
+ return (x == x) + (x != x) + (x > x)
+ + (x < x) + (x >= x) + (x <= x);
+}
+
+int
+main (int argc, char *argv[])
+{
+ vector (4, int) t = {argc, 2, argc, 42};
+ vector (4, int) r;
+ int i;
+
+ r = foo (t);
+
+ for (i = 0; i < 4; i++)
+ if (r[i] != -3)
+ __builtin_abort ();
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift.c
new file mode 100644
index 000000000..f690b7c3d
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+
+#define vector __attribute__((vector_size(sizeof(int)*4) ))
+
+static vector int allones = {1, 1, 1, 1};
+static vector int allzeros = {0, 0, 0, 0};
+static vector int numbers = {0, 1, 2, 3};
+static vector int numbersleftshiftallones = {0, 2, 4, 6};
+static vector int numbersrightshiftallones = {0, 0, 1, 1};
+
+
+static vector unsigned int uallones = {1, 1, 1, 1};
+static vector unsigned int uallzeros = {0, 0, 0, 0};
+static vector unsigned int unumbers = {0, 1, 2, 3};
+static vector unsigned int unumbersleftshiftallones = {0, 2, 4, 6};
+static vector unsigned int unumbersrightshiftallones = {0, 0, 1, 1};
+
+#define TEST(result, expected) \
+do { \
+ __typeof__(result) result1 = result; \
+ if(sizeof (result1) != sizeof (expected)) \
+ __builtin_abort (); \
+ if (__builtin_memcmp (&result1, &expected, sizeof(result1)) != 0) \
+ __builtin_abort (); \
+}while (0);
+
+int main(void)
+{
+ vector int result;
+ TEST ((numbers << allzeros), numbers);
+ TEST ((numbers >> allzeros), numbers);
+ TEST((numbers << allones), numbersleftshiftallones);
+ TEST((numbers >> allones), numbersrightshiftallones);
+ /* Test left shift followed by a right shift, numbers should be back as
+ numbers are all small numbers and no lose of precision happens. */
+ TEST((numbers << allones) >> allones, numbers);
+
+
+
+ TEST ((unumbers << uallzeros), unumbers);
+ TEST ((unumbers >> uallzeros), unumbers);
+ TEST((unumbers << uallones), unumbersleftshiftallones);
+ TEST((unumbers >> uallones), unumbersrightshiftallones);
+ /* Test left shift followed by a right shift, numbers should be back as
+ numbers are all small numbers and no lose of precision happens. */
+ TEST((unumbers << uallones) >> uallones, unumbers);
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift1.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift1.c
new file mode 100644
index 000000000..e6e31daf5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift1.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+#define vector __attribute__((vector_size(8*sizeof(short))))
+
+int main (int argc, char *argv[]) {
+ vector short v0 = {argc,2,3,4,5,6,7};
+ vector short v1 = {2,2,2,2,2,2,2};
+ vector short r1,r2,r3,r4;
+ int i = 8;
+
+ r1 = v0 << 1;
+ r2 = v0 >> 1;
+
+ r3 = v0 << v1;
+ r4 = v0 >> v1;
+
+ return 0;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift2.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift2.c
new file mode 100644
index 000000000..d3a2ef87c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-shift2.c
@@ -0,0 +1,60 @@
+/* { dg-do run } */
+#define vector(elcount, type) \
+__attribute__((vector_size((elcount)*sizeof(type)))) type
+
+#define vidx(type, vec, idx) (*((type *) &(vec) + idx))
+#define uint unsigned int
+
+int main (int argc, char *argv[]) {
+ vector(4, uint) vuint = { 1, 2, 3, 4};
+ vector(4, int) vint0 = { 1, 1, 1, 1};
+ vector(4, int) vint1 = {-1, -1, -1, -1};
+
+ vector(4, int) i1, i2, i3;
+ vector(4, uint) u1, u2, u3;
+
+ i1 = vint1<< vint0;
+
+ if (vidx(int, i1, 0) != ((int)-1 << (int)1))
+ __builtin_abort ();
+ if (vidx(int, i1, 1) != ((int)-1 << (int)1))
+ __builtin_abort ();
+ if (vidx(int, i1, 2) != ((int)-1 << (int)1))
+ __builtin_abort ();
+ if (vidx(int, i1, 3) != ((int)-1 << (int)1))
+ __builtin_abort ();
+
+ u1 = vuint << vint0;
+
+ if (vidx(int, u1, 0) != ((uint)1 << (int)1))
+ __builtin_abort ();
+ if (vidx(int, u1, 1) != ((uint)2 << (int)1))
+ __builtin_abort ();
+ if (vidx(int, u1, 2) != ((uint)3 << (int)1))
+ __builtin_abort ();
+ if (vidx(int, u1, 3) != ((uint)4 << (int)1))
+ __builtin_abort ();
+
+
+ i2 = vint1 >> vuint;
+
+ if (vidx(int, i2, 0) != ((int)-1 >> (uint)1))
+ __builtin_abort ();
+ if (vidx(int, i2, 1) != ((int)-1 >> (uint)2))
+ __builtin_abort ();
+ if (vidx(int, i2, 2) != ((int)-1 >> (uint)3))
+ __builtin_abort ();
+ if (vidx(int, i2, 3) != ((int)-1 >> (uint)4))
+ __builtin_abort ();
+
+
+ vint1 >>= vuint;
+
+ vuint <<= vint0;
+ vuint <<= vint1;
+
+
+ return 0;
+}
+
+
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-1.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-1.c
new file mode 100644
index 000000000..6152e7c78
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-1.c
@@ -0,0 +1,61 @@
+/* { dg-do run } */
+/* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */
+#define vector __attribute__((vector_size(sizeof(int)*4) ))
+
+/* Check to make sure that we extract and insert the vector at the same
+ location for vector subscripting and that vectors layout are the same
+ as arrays. */
+
+struct TV4
+{
+ vector int v;
+};
+
+typedef struct TV4 MYV4;
+static inline int *f(MYV4 *a, int i)
+{
+ return &(a->v[i]);
+}
+
+static inline MYV4 myfunc2( int x, int y, int z, int w )
+{
+ MYV4 temp;
+ *f(&temp, 0 ) = x;
+ *f(&temp, 1 ) = y;
+ *f(&temp, 2 ) = z;
+ *f(&temp, 3 ) = w;
+ return temp;
+}
+
+MYV4 val3;
+
+__attribute__((noinline)) void modify (void)
+{
+ val3 = myfunc2( 1, 2, 3, 4 );
+}
+
+int main( int argc, char* argv[] )
+{
+ int a[4];
+ int i;
+
+ modify();
+
+ if (*f(&val3, 0 ) != 1)
+ __builtin_abort ();
+ if (*f(&val3, 1 ) != 2)
+ __builtin_abort ();
+ if (*f(&val3, 2 ) != 3)
+ __builtin_abort ();
+ if (*f(&val3, 3 ) != 4)
+ __builtin_abort ();
+
+ __builtin_memcpy (a, &val3, sizeof(a));
+ for(i = 0; i < 4; i++)
+ if (a[i] != i+1)
+ __builtin_abort ();
+
+
+ return 0;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-2.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-2.c
new file mode 100644
index 000000000..202b3d95a
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-2.c
@@ -0,0 +1,69 @@
+/* { dg-do run } */
+/* { dg-options "-fno-common" { target hppa*-*-hpux* } } */
+#define vector __attribute__((vector_size(sizeof(int)*4) ))
+
+/* Check to make sure that we extract and insert the vector at the same
+ location for vector subscripting (with constant indexes) and
+ that vectors layout are the same as arrays. */
+
+struct TV4
+{
+ vector int v;
+};
+
+typedef struct TV4 MYV4;
+
+static inline MYV4 myfunc2( int x, int y, int z, int w )
+{
+ MYV4 temp;
+ temp.v[0] = x;
+ temp.v[1] = y;
+ temp.v[2] = z;
+ temp.v[3] = w;
+ return temp;
+}
+MYV4 val3;
+__attribute__((noinline)) void modify (void)
+{
+ val3 = myfunc2( 1, 2, 3, 4 );
+}
+int main( int argc, char* argv[] )
+{
+ int a[4];
+ int i;
+
+ /* Set up the vector. */
+ modify();
+
+ /* Check the vector via the global variable. */
+ if (val3.v[0] != 1)
+ __builtin_abort ();
+ if (val3.v[1] != 2)
+ __builtin_abort ();
+ if (val3.v[2] != 3)
+ __builtin_abort ();
+ if (val3.v[3] != 4)
+ __builtin_abort ();
+
+ vector int a1 = val3.v;
+
+ /* Check the vector via a local variable. */
+ if (a1[0] != 1)
+ __builtin_abort ();
+ if (a1[1] != 2)
+ __builtin_abort ();
+ if (a1[2] != 3)
+ __builtin_abort ();
+ if (a1[3] != 4)
+ __builtin_abort ();
+
+ __builtin_memcpy(a, &val3, sizeof(a));
+ /* Check the vector via copying it to an array. */
+ for(i = 0; i < 4; i++)
+ if (a[i] != i+1)
+ __builtin_abort ();
+
+
+ return 0;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c
new file mode 100644
index 000000000..bb5c91485
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vector-subscript-3.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+#define vector __attribute__((vector_size(16) ))
+
+/* Check whether register declaration of vector type still
+ allow us to subscript this type. */
+
+typedef vector short myvec_t;
+
+struct vec_s {
+ vector short member;
+};
+
+
+int main () {
+ register short vector v0 = {1,2,3,4,5,6,7};
+ register myvec_t v1 = {1,2,3,4,5,6,7};
+ register struct vec_s v2;
+
+ v2.member = v1;
+
+ short r = v0[0] + v1[1] + v2.member[2];
+ if (r != 6)
+ __builtin_abort ();
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-16.inc b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-16.inc
new file mode 100644
index 000000000..68f2646d8
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-16.inc
@@ -0,0 +1,81 @@
+/* Test fragment for vectors with 16 elements. */
+
+#ifndef UNSUPPORTED
+
+struct S
+{
+ V in;
+ VI mask;
+ V out;
+};
+
+struct S tests[] = {
+ {
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, },
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
+ },
+ {
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
+ { 0x10, 0x21, 0x32, 0x43, 0x54, 0x65, 0x76, 0x87,
+ 0x98, 0xa9, 0xba, 0xcb, 0xdc, 0xed, 0xfe, 0xff },
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
+ },
+ {
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
+ { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
+ { 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 },
+ },
+ {
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
+ { 0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15 },
+ { 1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16 },
+ },
+ {
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
+ { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
+ { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 },
+ },
+};
+
+struct S2
+{
+ V in1, in2;
+ VI mask;
+ V out;
+};
+
+struct S2 tests2[] = {
+ {
+ { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
+ { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 },
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
+ { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
+ },
+ {
+ { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
+ { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 },
+ { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 },
+ { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 },
+ },
+ {
+ { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
+ { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 },
+ { 7, 6, 5, 4, 16, 17, 18, 19, 31, 30, 29, 28, 3, 2, 1, 0 },
+ { 17, 16, 15, 14, 30, 31, 32, 33, 45, 44, 43, 42, 13, 12, 11, 10 },
+ },
+ {
+ { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
+ { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+ { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
+ },
+ {
+ { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
+ { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 },
+ { 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 },
+ { 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45 },
+ },
+};
+
+#endif
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-2.inc b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-2.inc
new file mode 100644
index 000000000..ef778e594
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-2.inc
@@ -0,0 +1,38 @@
+/* Test fragment for vectors of 2 elements. */
+
+#ifndef UNSUPPORTED
+
+struct S
+{
+ V in;
+ VI mask;
+ V out;
+};
+
+struct S tests[] = {
+ { { A, B }, { 0, 1 }, { A, B } },
+ { { A, B }, { -16, -1 }, { A, B } },
+ { { A, B }, { 1, 0 }, { B, A } },
+ { { A, B }, { 0, 0 }, { A, A } },
+ { { X, Y }, { 1, 1 }, { Y, Y } },
+ { { X, Y }, { 1, 0 }, { Y, X } },
+};
+
+struct S2
+{
+ V in1, in2;
+ VI mask;
+ V out;
+};
+
+struct S2 tests2[] = {
+ { { A, B }, { X, Y }, { 0, 1 }, { A, B } },
+ { { A, B }, { X, Y }, { 2, 3 }, { X, Y } },
+ { { A, B }, { X, Y }, { 0, 2 }, { A, X } },
+ { { A, B }, { X, Y }, { 2, 1 }, { X, B } },
+ { { A, B }, { X, Y }, { 3, 0 }, { Y, A } },
+ { { A, B }, { X, Y }, { 0, 0 }, { A, A } },
+ { { A, B }, { X, Y }, { 3, 3 }, { Y, Y } },
+};
+
+#endif
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-4.inc b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-4.inc
new file mode 100644
index 000000000..d6e6e1022
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-4.inc
@@ -0,0 +1,39 @@
+/* Test fragment for vectors of 4 elements. */
+
+#ifndef UNSUPPORTED
+
+struct S
+{
+ V in;
+ VI mask;
+ V out;
+};
+
+struct S tests[] = {
+ { { A, B, C, D }, { 0, 1, 2, 3 }, { A, B, C, D }, },
+ { { A, B, C, D }, { 0+1*4, 1+2*4, 2+3*4, 3+4*4 }, { A, B, C, D } },
+ { { A, B, C, D }, { 3, 2, 1, 0 }, { D, C, B, A } },
+ { { A, B, C, D }, { 0, 3, 2, 1 }, { A, D, C, B } },
+ { { A, B, C, D }, { 0, 2, 1, 3 }, { A, C, B, D } },
+ { { W, X, Y, Z }, { 3, 1, 2, 0 }, { Z, X, Y, W } },
+ { { W, X, Y, Z }, { 0, 0, 0, 0 }, { W, W, W, W } },
+ { { W, X, Y, Z }, { 1, 2, 1, 2 }, { X, Y, X, Y } },
+};
+
+struct S2
+{
+ V in1, in2;
+ VI mask;
+ V out;
+};
+
+struct S2 tests2[] = {
+ { { A, B, C, D }, { W, X, Y, Z }, { 0, 1, 2, 3 }, { A, B, C, D } },
+ { { A, B, C, D }, { W, X, Y, Z }, { 4, 5, 6, 7 }, { W, X, Y, Z } },
+ { { A, B, C, D }, { W, X, Y, Z }, { 0, 4, 1, 5 }, { A, W, B, X } },
+ { { A, B, C, D }, { W, X, Y, Z }, { 0, 7, 4, 3 }, { A, Z, W, D } },
+ { { A, B, C, D }, { W, X, Y, Z }, { 0, 0, 0, 0 }, { A, A, A, A } },
+ { { A, B, C, D }, { W, X, Y, Z }, { 7, 7, 7, 7 }, { Z, Z, Z, Z } },
+};
+
+#endif
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-8.inc b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-8.inc
new file mode 100644
index 000000000..e6475226a
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-8.inc
@@ -0,0 +1,101 @@
+/* Test fragment for vectors of 8 elements. */
+
+#ifndef UNSUPPORTED
+
+struct S
+{
+ V in;
+ VI mask;
+ V out;
+};
+
+struct S tests[] = {
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { 0, 1, 2, 3, 4, 5, 6, 7 },
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { 0x10, 0x21, 0x32, 0x43, 0x54, 0x65, 0x76, 0x87 },
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { 7, 6, 5, 4, 3, 2, 1, 0 },
+ { H1, G1, F1, E1, D1, C1, B1, A1 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { 7, 0, 5, 3, 2, 4, 1, 6 },
+ { H1, A1, F1, D1, C1, E1, B1, G1 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { 0, 2, 1, 3, 4, 6, 5, 7 },
+ { A1, C1, B1, D1, E1, G1, F1, H1 },
+ },
+ {
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 3, 1, 2, 0, 7, 5, 6, 4 },
+ { D2, B2, C2, A2, H2, F2, G2, E2 },
+ },
+ {
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 0, 0, 0, 0 },
+ { A2, A2, A2, A2, A2, A2, A2, A2 },
+ },
+ {
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 1, 6, 1, 6, 1, 6, 1, 6 },
+ { B2, G2, B2, G2, B2, G2, B2, G2 },
+ }
+};
+
+struct S2
+{
+ V in1, in2;
+ VI mask;
+ V out;
+};
+
+struct S2 tests2[] = {
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 0, 1, 2, 3, 4, 5, 6, 7 },
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 8, 9, 10, 11, 12, 13, 14, 15 },
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 0, 8, 1, 9, 2, 10, 3, 11 },
+ { A1, A2, B1, B2, C1, C2, D1, D2 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 0, 15, 4, 11, 12, 3, 7, 8 },
+ { A1, H2, E1, D2, E2, D1, H1, A2 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 0, 0, 0, 0, 0, 0, 0, 0 },
+ { A1, A1, A1, A1, A1, A1, A1, A1 },
+ },
+ {
+ { A1, B1, C1, D1, E1, F1, G1, H1 },
+ { A2, B2, C2, D2, E2, F2, G2, H2 },
+ { 0x1e, 0x2e, 0x3e, 0x4e, 0x5e, 0x6e, 0x7e, 0x8e },
+ { G2, G2, G2, G2, G2, G2, G2, G2 },
+ },
+};
+
+#endif
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-main.inc b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-main.inc
new file mode 100644
index 000000000..8487131b1
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-main.inc
@@ -0,0 +1,26 @@
+/* Driver fragment for __builtin_shuffle of any vector shape. */
+
+extern void abort(void);
+
+int main()
+{
+#ifndef UNSUPPORTED
+ int i;
+
+ for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+ {
+ V r = __builtin_shuffle(tests[i].in, tests[i].mask);
+ if (__builtin_memcmp(&r, &tests[i].out, sizeof(V)) != 0)
+ abort();
+ }
+
+ for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); ++i)
+ {
+ V r = __builtin_shuffle(tests2[i].in1, tests2[i].in2, tests2[i].mask);
+ if (__builtin_memcmp(&r, &tests2[i].out, sizeof(V)) != 0)
+ abort();
+ }
+#endif
+
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v16hi.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v16hi.c
new file mode 100644
index 000000000..98b329dbf
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v16hi.c
@@ -0,0 +1,5 @@
+typedef unsigned short V __attribute__((vector_size(32)));
+typedef V VI;
+
+#include "vshuf-16.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v16qi.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v16qi.c
new file mode 100644
index 000000000..dcd1de1e6
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v16qi.c
@@ -0,0 +1,5 @@
+typedef unsigned char V __attribute__((vector_size(16)));
+typedef V VI;
+
+#include "vshuf-16.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2df.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2df.c
new file mode 100644
index 000000000..e88ec08dd
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2df.c
@@ -0,0 +1,15 @@
+#if __SIZEOF_DOUBLE__ == 8 && __SIZEOF_LONG_LONG__ == 8
+typedef double V __attribute__((vector_size(16)));
+typedef unsigned long long VI __attribute__((vector_size(16)));
+#else
+#define UNSUPPORTED
+#endif
+
+#define A 0.69314718055994530942
+#define B 2.7182818284590452354
+
+#define X 3.14159265358979323846
+#define Y 1.41421356237309504880
+
+#include "vshuf-2.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2di.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2di.c
new file mode 100644
index 000000000..0985a0de0
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2di.c
@@ -0,0 +1,15 @@
+#if __SIZEOF_LONG_LONG__ == 8
+typedef unsigned long long V __attribute__((vector_size(16)));
+typedef V VI;
+#else
+#define UNSUPPORTED
+#endif
+
+#define A 0x1112131415161718
+#define B 0x2122232425262728
+
+#define X 0xc1c2c3c4c5c6c7c8
+#define Y 0xd1d2d3d4d5d6d7d8
+
+#include "vshuf-2.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2sf.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2sf.c
new file mode 100644
index 000000000..f9c40b223
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2sf.c
@@ -0,0 +1,21 @@
+#if __SIZEOF_FLOAT__ == 4
+typedef float V __attribute__((vector_size(8)));
+# if __SIZEOF_INT__ == 4
+typedef unsigned int VI __attribute__((vector_size(8)));
+# elif __SIZEOF_LONG__ == 4
+typedef unsigned long VI __attribute__((vector_size(8)));
+# else
+# define UNSUPPORTED
+# endif
+#else
+# define UNSUPPORTED
+#endif
+
+#define A 0.69314718055994530942f
+#define B 2.7182818284590452354f
+
+#define X 3.14159265358979323846f
+#define Y 1.41421356237309504880f
+
+#include "vshuf-2.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2si.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2si.c
new file mode 100644
index 000000000..414743c89
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v2si.c
@@ -0,0 +1,18 @@
+#if __SIZEOF_INT__ == 4
+typedef unsigned int V __attribute__((vector_size(8)));
+typedef V VI;
+#elif __SIZEOF_LONG__ == 4
+typedef unsigned long V __attribute__((vector_size(8)));
+typedef V VI;
+#else
+#define UNSUPPORTED
+#endif
+
+#define A 0x11121314
+#define B 0x21222324
+
+#define X 0xd1d2d3d4
+#define Y 0xe1e2e3e4
+
+#include "vshuf-2.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4df.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4df.c
new file mode 100644
index 000000000..c4030a7db
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4df.c
@@ -0,0 +1,19 @@
+#if __SIZEOF_DOUBLE__ == 8 && __SIZEOF_LONG_LONG__ == 8
+typedef double V __attribute__((vector_size(32)));
+typedef unsigned long long VI __attribute__((vector_size(32)));
+#else
+#define UNSUPPORTED
+#endif
+
+#define A 0.69314718055994530942
+#define B 2.7182818284590452354
+#define C 2.30258509299404568402
+#define D 1.4426950408889634074
+
+#define W 0.31830988618379067154
+#define X 3.14159265358979323846
+#define Y 1.41421356237309504880
+#define Z 0.70710678118654752440
+
+#include "vshuf-4.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4di.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4di.c
new file mode 100644
index 000000000..a84aebefb
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4di.c
@@ -0,0 +1,19 @@
+#if __SIZEOF_LONG_LONG__ == 8
+typedef unsigned long long V __attribute__((vector_size(32)));
+typedef V VI;
+#else
+#define UNSUPPORTED
+#endif
+
+#define A 0x1112131415161718
+#define B 0x2122232425262728
+#define C 0x3132333435363738
+#define D 0x4142434445464748
+
+#define W 0xc1c2c3c4c5c6c7c8
+#define X 0xd1d2d3d4d5d6d7d8
+#define Y 0xe1e2e3e4e5e6e7e8
+#define Z 0xf1f2f3f4f5f6f7f8
+
+#include "vshuf-4.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4hi.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4hi.c
new file mode 100644
index 000000000..64a2bb4ac
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4hi.c
@@ -0,0 +1,15 @@
+typedef unsigned short V __attribute__((vector_size(8)));
+typedef V VI;
+
+#define A 0x1112
+#define B 0x2122
+#define C 0x3132
+#define D 0x4142
+
+#define W 0xc1c2
+#define X 0xd1d2
+#define Y 0xe1e2
+#define Z 0xf1f2
+
+#include "vshuf-4.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4sf.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4sf.c
new file mode 100644
index 000000000..283672560
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4sf.c
@@ -0,0 +1,25 @@
+#if __SIZEOF_FLOAT__ == 4
+typedef float V __attribute__((vector_size(16)));
+# if __SIZEOF_INT__ == 4
+typedef unsigned int VI __attribute__((vector_size(16)));
+# elif __SIZEOF_LONG__ == 4
+typedef unsigned long VI __attribute__((vector_size(16)));
+# else
+# define UNSUPPORTED
+# endif
+#else
+# define UNSUPPORTED
+#endif
+
+#define A 0.69314718055994530942f
+#define B 2.7182818284590452354f
+#define C 2.30258509299404568402f
+#define D 1.4426950408889634074f
+
+#define W 0.31830988618379067154f
+#define X 3.14159265358979323846f
+#define Y 1.41421356237309504880f
+#define Z 0.70710678118654752440f
+
+#include "vshuf-4.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4si.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4si.c
new file mode 100644
index 000000000..289ec1b50
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v4si.c
@@ -0,0 +1,22 @@
+#if __SIZEOF_INT__ == 4
+typedef unsigned int V __attribute__((vector_size(16)));
+typedef V VI;
+#elif __SIZEOF_LONG__ == 4
+typedef unsigned long V __attribute__((vector_size(16)));
+typedef V VI;
+#else
+# define UNSUPPORTED
+#endif
+
+#define A 0x11121314
+#define B 0x21222324
+#define C 0x31323334
+#define D 0x41424344
+
+#define W 0xc1c2c3c4
+#define X 0xd1d2d3d4
+#define Y 0xe1e2e3e4
+#define Z 0xf1f2f3f4
+
+#include "vshuf-4.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8hi.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8hi.c
new file mode 100644
index 000000000..ce442c5d9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8hi.c
@@ -0,0 +1,23 @@
+typedef unsigned short V __attribute__((vector_size(16)));
+typedef V VI;
+
+#define A1 0x1112
+#define B1 0x2122
+#define C1 0x3132
+#define D1 0x4142
+#define E1 0x5152
+#define F1 0x6162
+#define G1 0x7172
+#define H1 0x8182
+
+#define A2 0x9192
+#define B2 0xa1a2
+#define C2 0xb1b2
+#define D2 0xc1c2
+#define E2 0xd1d2
+#define F2 0xe1e2
+#define G2 0xf1f2
+#define H2 0x0102
+
+#include "vshuf-8.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8qi.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8qi.c
new file mode 100644
index 000000000..349ec6db6
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8qi.c
@@ -0,0 +1,23 @@
+typedef unsigned char V __attribute__((vector_size(8)));
+typedef V VI;
+
+#define A1 0x11
+#define B1 0x12
+#define C1 0x13
+#define D1 0x14
+#define E1 0x15
+#define F1 0x16
+#define G1 0x17
+#define H1 0x18
+
+#define A2 0xf1
+#define B2 0xf2
+#define C2 0xf3
+#define D2 0xf4
+#define E2 0xf5
+#define F2 0xf6
+#define G2 0xf7
+#define H2 0xf8
+
+#include "vshuf-8.inc"
+#include "vshuf-main.inc"
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8si.c b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8si.c
new file mode 100644
index 000000000..5b0a2c33e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/torture/vshuf-v8si.c
@@ -0,0 +1,30 @@
+#if __SIZEOF_INT__ == 4
+typedef unsigned int V __attribute__((vector_size(32)));
+typedef V VI;
+#elif __SIZEOF_LONG__ == 4
+typedef unsigned long V __attribute__((vector_size(32)));
+typedef V VI;
+#else
+# define UNSUPPORTED
+#endif
+
+#define A1 0x11121314
+#define B1 0x21222324
+#define C1 0x31323334
+#define D1 0x41424344
+#define E1 0x51525354
+#define F1 0x61626364
+#define G1 0x71727374
+#define H1 0x81828384
+
+#define A2 0x91929394
+#define B2 0xa1a2a3a4
+#define C2 0xb1b2b3b4
+#define D2 0xc1c2c3c4
+#define E2 0xd1d2d3d4
+#define F2 0xe1e2e3e4
+#define G2 0xf1f2f3f4
+#define H2 0x01020304
+
+#include "vshuf-8.inc"
+#include "vshuf-main.inc"