This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/3] Fix vect-shuffle-* test cases.


---
 gcc/testsuite/ChangeLog                            |   11 ++
 .../gcc.c-torture/execute/vect-shuffle-1.c         |   98 +++++++++++-------
 .../gcc.c-torture/execute/vect-shuffle-2.c         |   96 +++++++++++------
 .../gcc.c-torture/execute/vect-shuffle-3.c         |   90 ++++++++++------
 .../gcc.c-torture/execute/vect-shuffle-4.c         |   99 +++++++++---------
 .../gcc.c-torture/execute/vect-shuffle-5.c         |  113 ++++++++++----------
 .../gcc.c-torture/execute/vect-shuffle-6.c         |   64 +++++++++++
 .../gcc.c-torture/execute/vect-shuffle-7.c         |   70 ++++++++++++
 .../gcc.c-torture/execute/vect-shuffle-8.c         |   55 ++++++++++
 9 files changed, 482 insertions(+), 214 deletions(-)
 create mode 100644 gcc/testsuite/gcc.c-torture/execute/vect-shuffle-6.c
 create mode 100644 gcc/testsuite/gcc.c-torture/execute/vect-shuffle-7.c
 create mode 100644 gcc/testsuite/gcc.c-torture/execute/vect-shuffle-8.c

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4a09d43..eff558f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2011-10-05  Richard Henderson  <rth@redhat.com>
+
+	* gcc.c-torture/execute/vect-shuffle-1.c: Rewrite.
+	* gcc.c-torture/execute/vect-shuffle-2.c: Rewrite.
+	* gcc.c-torture/execute/vect-shuffle-3.c: Rewrite.
+	* gcc.c-torture/execute/vect-shuffle-4.c: Rewrite.
+	* gcc.c-torture/execute/vect-shuffle-5.c: Rewrite.
+	* gcc.c-torture/execute/vect-shuffle-6.c: New test.
+	* gcc.c-torture/execute/vect-shuffle-7.c: New test.
+	* gcc.c-torture/execute/vect-shuffle-8.c: New test.
+
 2011-10-05  Richard Guenther  <rguenther@suse.de>
 
 	PR tree-optimization/38885
diff --git a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-1.c b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-1.c
index 20f0261..3b83636 100644
--- a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-1.c
@@ -1,46 +1,68 @@
-#define vector(elcount, type)  \
-__attribute__((vector_size((elcount)*sizeof(type)))) type
+#if __SIZEOF_INT__ == 4
+typedef unsigned int V __attribute__((vector_size(16), may_alias));
 
-#define vidx(type, vec, idx) (*(((type *) &(vec)) + idx))
+struct S
+{
+  V in, mask, out;
+};
 
-#define shufcompare(type, count, vres, v0, mask) \
-do { \
-    int __i; \
-    for (__i = 0; __i < count; __i++) { \
-        if (vidx(type, vres, __i) != vidx(type, v0, vidx(type, mask, __i))) \
-            __builtin_abort (); \
-    } \
-} while (0)
+struct S tests[] = {
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0, 1, 2, 3 },
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0+1*4, 1+2*4, 2+3*4, 3+4*4 },
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 3, 2, 1, 0 },
+    { 0x44444444, 0x33333333, 0x22222222, 0x11111111 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0, 3, 2, 1 },
+    { 0x11111111, 0x44444444, 0x33333333, 0x22222222 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0, 2, 1, 3 },
+    { 0x11111111, 0x33333333, 0x22222222, 0x44444444 },
+  },
+  {
+    { 0x11223344, 0x55667788, 0x99aabbcc, 0xddeeff00 },
+    { 3, 1, 2, 0 },
+    { 0xddeeff00, 0x55667788, 0x99aabbcc, 0x11223344 },
+  },
+  {
+    { 0x11223344, 0x55667788, 0x99aabbcc, 0xddeeff00 },
+    { 0, 0, 0, 0 },
+    { 0x11223344, 0x11223344, 0x11223344, 0x11223344 },
+  },
+  {
+    { 0x11223344, 0x55667788, 0x99aabbcc, 0xddeeff00 },
+    { 1, 2, 1, 2 },
+    { 0x55667788, 0x99aabbcc, 0x55667788, 0x99aabbcc },
+  }
+};
 
+extern void abort(void);
 
-int main (int argc, char *argv[]) {
-    /*vector (8, short) v0 = {argc, 1,2,3,4,5,6,7};
-    vector (8, short) v1 = {argc, 1,argc,3,4,5,argc,7};
-    vector (8, short) v2;
+int main()
+{
+  int i;
 
-    vector (8, short) smask = {0,0,1,2,3,4,5,6};
+  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();
+    }
 
-    v2 = __builtin_shuffle (v0,  smask);
-    shufcompare (short, 8, v2, v0, smask);
-    v2 = __builtin_shuffle (v0, v1);
-    shufcompare (short, 8, v2, v0, v1);
-    v2 = __builtin_shuffle (smask, v0);
-    shufcompare (short, 8, v2, smask, v0);*/
-
-    vector (4, int) i0 = {argc, 1,2,3};
-    vector (4, int) i1 = {argc, 1, argc, 3};
-    vector (4, int) i2;
-
-    vector (4, int) imask = {0,3,2,1};
-
-    /*i2 = __builtin_shuffle (i0, imask);
-    shufcompare (int, 4, i2, i0, imask);*/
-    i2 = __builtin_shuffle (i0, i1);
-    shufcompare (int, 4, i2, i0, i1);
-
-    i2 = __builtin_shuffle (imask, i0);
-    shufcompare (int, 4, i2, imask, i0);
-
-    return 0;
+  return 0;
 }
 
+#endif /* SIZEOF_INT */
diff --git a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-2.c b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-2.c
index d886ad4..68ae225 100644
--- a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-2.c
@@ -1,44 +1,68 @@
-#define vector(elcount, type)  \
-__attribute__((vector_size((elcount)*sizeof(type)))) type
+#if __SIZEOF_SHORT__ == 2
+typedef unsigned short V __attribute__((vector_size(16), may_alias));
 
-#define vidx(type, vec, idx) (*(((type *) &(vec)) + idx))
+struct S
+{
+  V in, mask, out;
+};
 
-#define shuf2compare(type, count, vres, v0, v1, mask) \
-do { \
-    int __i; \
-    for (__i = 0; __i < count; __i++) { \
-        if (vidx(type, vres, __i) != ((vidx(type, mask, __i) < count) ? \
-                          vidx(type, v0, vidx(type, mask, __i)) :  \
-                          vidx(type, v1, (vidx(type, mask, __i) - count)))) \
-            __builtin_abort (); \
-        } \
-} while (0)
+struct S tests[] = {
+  {
+    { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 },
+    { 0, 1, 2, 3, 4, 5, 6, 7 },
+    { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 },
+  },
+  {
+    { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 },
+    { 0x10, 0x21, 0x32, 0x43, 0x54, 0x65, 0x76, 0x87 },
+    { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 },
+  },
+  {
+    { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 },
+    { 7, 6, 5, 4, 3, 2, 1, 0 },
+    { 0x8888, 0x7777, 0x6666, 0x5555, 0x4444, 0x3333, 0x2222, 0x1111 },
+  },
+  {
+    { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 },
+    { 7, 0, 5, 3, 2, 4, 1, 6 },
+    { 0x8888, 0x1111, 0x6666, 0x4444, 0x3333, 0x5555, 0x2222, 0x7777 },
+  },
+  {
+    { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 },
+    { 0, 2, 1, 3, 4, 6, 5, 7 },
+    { 0x1111, 0x3333, 0x2222, 0x4444, 0x5555, 0x7777, 0x6666, 0x8888 },
+  },
+  {
+    { 0x1122, 0x3344, 0x5566, 0x7788, 0x99aa, 0xbbcc, 0xddee, 0xff00 },
+    { 3, 1, 2, 0, 7, 5, 6, 4 },
+    { 0x7788, 0x3344, 0x5566, 0x1122, 0xff00, 0xbbcc, 0xddee, 0x99aa },
+  },
+  {
+    { 0x1122, 0x3344, 0x5566, 0x7788, 0x99aa, 0xbbcc, 0xddee, 0xff00 },
+    { 0, 0, 0, 0 },
+    { 0x1122, 0x1122, 0x1122, 0x1122, 0x1122, 0x1122, 0x1122, 0x1122 },
+  },
+  {
+    { 0x1122, 0x3344, 0x5566, 0x7788, 0x99aa, 0xbbcc, 0xddee, 0xff00 },
+    { 1, 6, 1, 6, 1, 6, 1, 6 }, 
+    { 0x3344, 0xddee, 0x3344, 0xddee, 0x3344, 0xddee, 0x3344, 0xddee },
+  }
+};
 
+extern void abort(void);
 
-int main (int argc, char *argv[]) {
-    vector (8, short) v0 = {5, 5,5,5,5,5,argc,7};
-    vector (8, short) v1 = {argc, 1,8,8,4,9,argc,4};
-    vector (8, short) v2;
+int main()
+{
+  int i;
 
-    //vector (8, short) mask = {1,2,5,4,3,6,7};
+  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+    {
+      V r = __builtin_shuffle(tests[i].in, tests[i].mask);
+      if (memcmp(&r, &tests[i].out, sizeof(V)) != 0)
+	abort();
+    }
 
-    vector (8, short) mask0 = {0,2,3,1,4,5,6,7};
-    vector (8, short) mask1 = {0,12,3,4,3,0,10,9};
-
-    vector (8, short) mask2 = {0,8,1,9,2,10,3,11};
-
-    v2 = __builtin_shuffle (v0, v1,  mask0);
-    shuf2compare (short, 8, v2, v0, v1, mask0);
-
-    v2 = __builtin_shuffle (v0, v1,  mask1);
-    shuf2compare (short, 8, v2, v0, v1, mask1);
-
-    v2 = __builtin_shuffle (v0, v1,  mask2);
-    shuf2compare (short, 8, v2, v0, v1, mask2);
-
-    v2 = __builtin_shuffle (mask0, mask0,  v0);
-    shuf2compare (short, 8, v2, mask0, mask0, v0);
-
-    return 0;
+  return 0;
 }
 
+#endif /* SIZEOF_SHORT */
diff --git a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-3.c b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-3.c
index 91e26fb..96aee65 100644
--- a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-3.c
+++ b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-3.c
@@ -1,36 +1,58 @@
-#define vector(elcount, type)  \
-__attribute__((vector_size((elcount)*sizeof(type)))) type
-
-#define vidx(type, vec, idx) (*(((type *) &(vec)) + idx))
-
-#define shufcompare(type, count, vres, v0, mask) \
-do { \
-    int __i; \
-    for (__i = 0; __i < count; __i++) { \
-        if (vidx(type, vres, __i) != vidx(type, v0, vidx(type, mask, __i))) \
-            __builtin_abort (); \
-    } \
-} while (0)
-
-vector (8, short) __attribute__ ((noinline))
-f (vector (8, short) x, vector (8, short) mask) {
-    return __builtin_shuffle (x, mask);
-}
-
-
-int main (int argc, char *argv[]) {
-    vector (8, short) v0 = {argc, 1,2,3,4,5,6,7};
-    vector (8, short) v1 = {argc, 1,argc,3,4,5,argc,7};
-    vector (8, short) v2;
-
-    vector (8, short) mask = {0,0,1,2,3,4,5,6};
-
-    v2 = f (v0,  mask);
-    shufcompare (short, 8, v2, v0, mask);
-
-    v2 = f (v0, v1);
-    shufcompare (short, 8, v2, v0, v1);
-
-    return 0;
+#if __SIZEOF_LONG_LONG__ == 8
+typedef unsigned long long V __attribute__((vector_size(16), may_alias));
+
+struct S
+{
+  V in, mask, out;
+};
+
+struct S tests[] = {
+  {
+    { 0x1111111111111111, 0x2222222222222222 },
+    { 0, 1 },
+    { 0x1111111111111111, 0x2222222222222222 },
+  },
+  {
+    { 0x1111111111111111, 0x2222222222222222 },
+    { 0x0102030405060700, 0xffeeddccbbaa99f1 },
+    { 0x1111111111111111, 0x2222222222222222 },
+  },
+  {
+    { 0x1111111111111111, 0x2222222222222222 },
+    { 1, 0 },
+    { 0x2222222222222222, 0x1111111111111111 },
+  },
+  {
+    { 0x1111111111111111, 0x2222222222222222 },
+    { 0, 0 },
+    { 0x1111111111111111, 0x1111111111111111 },
+  },
+  {
+    { 0x1122334455667788, 0x99aabbccddeeff00 },
+    { 1, 1 },
+    { 0x99aabbccddeeff00, 0x99aabbccddeeff00 },
+  },
+  {
+    { 0x1122334455667788, 0x99aabbccddeeff00 },
+    { 1, 0 },
+    { 0x99aabbccddeeff00, 0x1122334455667788 },
+  },
+};
+
+extern void abort(void);
+
+int main()
+{
+  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();
+    }
+
+  return 0;
 }
 
+#endif /* SIZEOF_LONG_LONG */
diff --git a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-4.c b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-4.c
index 04b8712..fa036eb 100644
--- a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-4.c
+++ b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-4.c
@@ -1,50 +1,51 @@
-#define vector(elcount, type)  \
-__attribute__((vector_size((elcount)*sizeof(type)))) type
-
-#define vidx(type, vec, idx) (*(((type *) &(vec)) + idx))
-
-#define shuf2compare(type, count, vres, v0, v1, mask) \
-do { \
-    int __i; \
-    for (__i = 0; __i < count; __i++) { \
-        if (vidx(type, vres, __i) != ((vidx(type, mask, __i) < count) ? \
-                          vidx(type, v0, vidx(type, mask, __i)) :  \
-                          vidx(type, v1, (vidx(type, mask, __i) - count)))) \
-            __builtin_abort (); \
-        } \
-} while (0)
-
-
-vector (8, short) __attribute__ ((noinline))
-f (vector (8, short) x, vector (8, short) y, vector (8, short) mask) {
-    return __builtin_shuffle (x, y, mask);
-}
-
-
-
-int main (int argc, char *argv[]) {
-    vector (8, short) v0 = {argc, 1,2,3,4,5,6,7};
-    vector (8, short) v1 = {argc, 1,argc,3,4,5,argc,7};
-    vector (8, short) v2;
-
-    //vector (8, short) mask = {1,2,5,4,3,6,7};
-
-    vector (8, short) mask0 = {0,2,3,1,4,5,6,7};
-    vector (8, short) mask1 = {0,12,3,4,3,0,10,9};
-    vector (8, short) mask2 = {0,8,1,9,2,10,3,11};
-
-    v2 = f (v0, v1,  mask0);
-    shuf2compare (short, 8, v2, v0, v1, mask0);
-
-    v2 = f (v0, v1,  mask1);
-    shuf2compare (short, 8, v2, v0, v1, mask1);
-
-    v2 = f (v0, v1,  mask2);
-    shuf2compare (short, 8, v2, v0, v1, mask2);
-
-    v2 = f (mask0, mask0,  v0);
-    shuf2compare (short, 8, v2, mask0, mask0, v0);
-
-    return 0;
+typedef unsigned char V __attribute__((vector_size(16), may_alias));
+
+struct S
+{
+  V in, mask, 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 }, 
+  },
+};
+
+extern void abort(void);
+
+int main()
+{
+  int i;
+
+  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+    {
+      V r = __builtin_shuffle(tests[i].in, tests[i].mask);
+      if (memcmp(&r, &tests[i].out, sizeof(V)) != 0)
+	abort();
+    }
+
+  return 0;
 }
-
diff --git a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-5.c b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-5.c
index b5f566a..f07025d 100644
--- a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-5.c
+++ b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-5.c
@@ -1,65 +1,64 @@
-/* Test that different type variants are compatible within
-   vector shuffling.  */
+#if __SIZEOF_INT__ == 4
+typedef unsigned int V __attribute__((vector_size(16), may_alias));
 
-#define vector(elcount, type)  \
-__attribute__((vector_size((elcount)*sizeof(type)))) type
+struct S
+{
+  V in1, in2, mask, out;
+};
 
-#define shufcompare(count, vres, v0, mask) \
-do { \
-    int __i; \
-    for (__i = 0; __i < count; __i++) { \
-        if (vres[__i] != v0[mask[__i]]) \
-            __builtin_abort (); \
-    } \
-} while (0)
+struct S tests[] = {
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0x55555555, 0x66666666, 0x77777777, 0x88888888 },
+    { 0, 1, 2, 3 },
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0x55555555, 0x66666666, 0x77777777, 0x88888888 },
+    { 4, 5, 6, 7 },
+    { 0x55555555, 0x66666666, 0x77777777, 0x88888888 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0x55555555, 0x66666666, 0x77777777, 0x88888888 },
+    { 0, 4, 1, 5 },
+    { 0x11111111, 0x55555555, 0x22222222, 0x66666666 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0x55555555, 0x66666666, 0x77777777, 0x88888888 },
+    { 0, 7, 4, 3 },
+    { 0x11111111, 0x88888888, 0x55555555, 0x44444444 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0x55555555, 0x66666666, 0x77777777, 0x88888888 },
+    { 0, 0, 0, 0 },
+    { 0x11111111, 0x11111111, 0x11111111, 0x11111111 },
+  },
+  {
+    { 0x11111111, 0x22222222, 0x33333333, 0x44444444 },
+    { 0x55555555, 0x66666666, 0x77777777, 0x88888888 },
+    { 7, 7, 7, 7 },
+    { 0x88888888, 0x88888888, 0x88888888, 0x88888888 },
+  },
+};
 
-#define test_compat_mask(res, vec, mask) \
-  res = __builtin_shuffle (vec, mask); \
-  shufcompare(4, res, vec, mask); \
-  res = __builtin_shuffle (vec, c ## mask); \
-  shufcompare(4, res, vec, c ##  mask); \
-  res = __builtin_shuffle (vec, r ## mask); \
-  shufcompare(4, res, vec, r ##  mask); \
-  res = __builtin_shuffle (vec, d ## mask); \
-  shufcompare(4, res, vec, d ##  mask); \
-  res = __builtin_shuffle (vec, dc ## mask); \
-  shufcompare(4, res, vec, dc ##  mask); \
+extern void abort(void);
 
-#define test_compat_vec(res, vec, mask) \
-  test_compat_mask (res, vec, mask); \
-  test_compat_mask (res, c ## vec, mask); \
-  test_compat_mask (res, r ## vec, mask); \
-  test_compat_mask (res, d ## vec, mask); \
-  test_compat_mask (res, dc ## vec, mask);
+int main()
+{
+  int i;
 
-#define test_compat(res, vec, mask) \
-  test_compat_vec (res, vec, mask); \
-  test_compat_vec (d ## res, vec, mask); \
-  test_compat_vec (r ## res, vec, mask);
+  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+    {
+      V r = __builtin_shuffle(tests[i].in1, tests[i].in2, tests[i].mask);
+      if (__builtin_memcmp(&r, &tests[i].out, sizeof(V)) != 0)
+	abort();
+    }
 
-typedef vector (4, int) v4si;
-typedef const vector (4, int) v4sicst;
-
-int main (int argc, char *argv[]) {
-    vector (4, int) vec = {argc, 1,2,3};
-    const vector (4, int) cvec = {argc, 1,2,3};
-    register vector (4, int) rvec = {argc, 1,2,3};
-    v4si dvec = {argc, 1,2,3};
-    v4sicst dcvec = {argc, 1,2,3};
-
-    vector (4, int) res;
-    v4si dres;
-    register vector (4, int) rres;
-
-    vector (4, int) mask = {0,3,2,1};
-    const vector (4, int) cmask = {0,3,2,1};
-    register vector (4, int) rmask = {0,3,2,1};
-    v4si dmask = {0,3,2,1};
-    v4sicst dcmask = {0,3,2,1};
-
-    test_compat (res, vec, mask);
-
-    return 0;
+  return 0;
 }
 
-
+#endif /* SIZEOF_INT */
diff --git a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-6.c b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-6.c
new file mode 100644
index 0000000..63eaf96
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-6.c
@@ -0,0 +1,64 @@
+#if __SIZEOF_SHORT__ == 2
+typedef unsigned short V __attribute__((vector_size(16), may_alias));
+
+struct S
+{
+  V in1, in2, mask, out;
+};
+
+struct S tests[] = {
+  {
+    { 0x1010, 0x2121, 0x3232, 0x4343, 0x5454, 0x6565, 0x7676, 0x8787 },
+    { 0x9898, 0xa9a9, 0xbaba, 0xcbcb, 0xdcdc, 0xeded, 0xfefe, 0x0f0f },
+    { 0, 1, 2, 3, 4, 5, 6, 7 },
+    { 0x1010, 0x2121, 0x3232, 0x4343, 0x5454, 0x6565, 0x7676, 0x8787 },
+  },
+  {
+    { 0x1010, 0x2121, 0x3232, 0x4343, 0x5454, 0x6565, 0x7676, 0x8787 },
+    { 0x9898, 0xa9a9, 0xbaba, 0xcbcb, 0xdcdc, 0xeded, 0xfefe, 0x0f0f },
+    { 8, 9, 10, 11, 12, 13, 14, 15 },
+    { 0x9898, 0xa9a9, 0xbaba, 0xcbcb, 0xdcdc, 0xeded, 0xfefe, 0x0f0f },
+  },
+  {
+    { 0x1010, 0x2121, 0x3232, 0x4343, 0x5454, 0x6565, 0x7676, 0x8787 },
+    { 0x9898, 0xa9a9, 0xbaba, 0xcbcb, 0xdcdc, 0xeded, 0xfefe, 0x0f0f },
+    { 0, 8, 1, 9, 2, 10, 3, 11 },
+    { 0x1010, 0x9898, 0x2121, 0xa9a9, 0x3232, 0xbaba, 0x4343, 0xcbcb },
+  },
+  {
+    { 0x1010, 0x2121, 0x3232, 0x4343, 0x5454, 0x6565, 0x7676, 0x8787 },
+    { 0x9898, 0xa9a9, 0xbaba, 0xcbcb, 0xdcdc, 0xeded, 0xfefe, 0x0f0f },
+    { 0, 15, 4, 11, 12, 3, 7, 8 },
+    { 0x1010, 0x0f0f, 0x5454, 0xcbcb, 0xdcdc, 0x4343, 0x8787, 0x9898 },
+  },
+  {
+    { 0x1010, 0x2121, 0x3232, 0x4343, 0x5454, 0x6565, 0x7676, 0x8787 },
+    { 0x9898, 0xa9a9, 0xbaba, 0xcbcb, 0xdcdc, 0xeded, 0xfefe, 0x0f0f },
+    { 0, 0, 0, 0, 0, 0, 0, 0 },
+    { 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010 },
+  },
+  {
+    { 0x1010, 0x2121, 0x3232, 0x4343, 0x5454, 0x6565, 0x7676, 0x8787 },
+    { 0x9898, 0xa9a9, 0xbaba, 0xcbcb, 0xdcdc, 0xeded, 0xfefe, 0x0f0f },
+    { 14, 14, 14, 14, 14, 14, 14, 14 },
+    { 0xfefe, 0xfefe, 0xfefe, 0xfefe, 0xfefe, 0xfefe, 0xfefe, 0xfefe },
+  },
+};
+
+extern void abort(void);
+
+int main()
+{
+  int i;
+
+  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+    {
+      V r = __builtin_shuffle(tests[i].in1, tests[i].in2, tests[i].mask);
+      if (__builtin_memcmp(&r, &tests[i].out, sizeof(V)) != 0)
+	abort();
+    }
+
+  return 0;
+}
+
+#endif /* SIZEOF_SHORT */
diff --git a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-7.c b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-7.c
new file mode 100644
index 0000000..3336c6f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-7.c
@@ -0,0 +1,70 @@
+#if __SIZEOF_LONG_LONG__ == 8
+typedef unsigned long long V __attribute__((vector_size(16), may_alias));
+
+struct S
+{
+  V in1, in2, mask, out;
+};
+
+struct S tests[] = {
+  {
+    { 0x1112131415161718, 0x2122232425262728 },
+    { 0x3132333435363738, 0x4142434445464748 },
+    { 0, 1 },
+    { 0x1112131415161718, 0x2122232425262728 },
+  },
+  {
+    { 0x1112131415161718, 0x2122232425262728 },
+    { 0x3132333435363738, 0x4142434445464748 },
+    { 2, 3 },
+    { 0x3132333435363738, 0x4142434445464748 },
+  },
+  {
+    { 0x1112131415161718, 0x2122232425262728 },
+    { 0x3132333435363738, 0x4142434445464748 },
+    { 0, 2 },
+    { 0x1112131415161718, 0x3132333435363738 },
+  },
+  {
+    { 0x1112131415161718, 0x2122232425262728 },
+    { 0x3132333435363738, 0x4142434445464748 },
+    { 2, 1 },
+    { 0x3132333435363738, 0x2122232425262728 },
+  },
+  {
+    { 0x1112131415161718, 0x2122232425262728 },
+    { 0x3132333435363738, 0x4142434445464748 },
+    { 3, 0 },
+    { 0x4142434445464748, 0x1112131415161718 },
+  },
+  {
+    { 0x1112131415161718, 0x2122232425262728 },
+    { 0x3132333435363738, 0x4142434445464748 },
+    { 0, 0 },
+    { 0x1112131415161718, 0x1112131415161718 },
+  },
+  {
+    { 0x1112131415161718, 0x2122232425262728 },
+    { 0x3132333435363738, 0x4142434445464748 },
+    { 3, 3 },
+    { 0x4142434445464748, 0x4142434445464748 },
+  },
+};
+
+extern void abort(void);
+
+int main()
+{
+  int i;
+
+  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+    {
+      V r = __builtin_shuffle(tests[i].in1, tests[i].in2, tests[i].mask);
+      if (__builtin_memcmp(&r, &tests[i].out, sizeof(V)) != 0)
+	abort();
+    }
+
+  return 0;
+}
+
+#endif /* SIZEOF_LONG_LONG */
diff --git a/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-8.c b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-8.c
new file mode 100644
index 0000000..f98e6ec
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/vect-shuffle-8.c
@@ -0,0 +1,55 @@
+typedef unsigned char V __attribute__((vector_size(16), may_alias));
+
+struct S
+{
+  V in1, in2, mask, out;
+};
+
+struct S tests[] = {
+  {
+    { 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 },
+  },
+};
+
+extern void abort(void);
+
+int main()
+{
+  int i;
+
+  for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+    {
+      V r = __builtin_shuffle(tests[i].in1, tests[i].in2, tests[i].mask);
+      if (__builtin_memcmp(&r, &tests[i].out, sizeof(V)) != 0)
+	abort();
+    }
+
+  return 0;
+}
-- 
1.7.6.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]