aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/i386/sse-7.c
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.target/i386/sse-7.c
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/i386/sse-7.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/i386/sse-7.c124
1 files changed, 124 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/i386/sse-7.c b/gcc-4.9/gcc/testsuite/gcc.target/i386/sse-7.c
new file mode 100644
index 000000000..30e2c13ba
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/i386/sse-7.c
@@ -0,0 +1,124 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -msse" } */
+/* { dg-require-effective-target sse } */
+
+#include "sse-check.h"
+
+#include <xmmintrin.h>
+#include <string.h>
+
+#define SHIFT (4)
+
+typedef union {
+ __m64 v;
+ unsigned char c[8];
+ unsigned short int s[4];
+ unsigned long long t;
+ unsigned int u[2];
+}vecInWord;
+
+void sse_tests (void) __attribute__((noinline));
+void dump64_16 (char *, char *, vecInWord);
+int check (const char *, const char *[]);
+
+char buf[8000];
+char comparison[8000];
+static int errors = 0;
+
+vecInWord c64, e64;
+__m64 m64_64;
+
+const char *reference_sse[] = {
+ "_mm_shuffle_pi16 0123 4567 89ab cdef \n",
+ ""
+};
+
+static void
+sse_test (void)
+{
+ e64.t = 0x0123456789abcdefULL;
+
+ m64_64 = e64.v;
+
+ sse_tests();
+ check (buf, reference_sse);
+#ifdef DEBUG
+ printf ("sse testing:\n");
+ printf (buf);
+ printf ("\ncomparison:\n");
+ printf (comparison);
+#endif
+ buf[0] = '\0';
+
+ if (errors != 0)
+ abort ();
+}
+
+void __attribute__((noinline))
+sse_tests (void)
+{
+ /* pshufw */
+ c64.v = _mm_shuffle_pi16 (m64_64, 0x1b);
+ dump64_16 (buf, "_mm_shuffle_pi16", c64);
+}
+
+void
+dump64_16 (char *buf, char *name, vecInWord x)
+{
+ int i;
+ char *p = buf + strlen (buf);
+
+ sprintf (p, "%s ", name);
+ p += strlen (p);
+
+ for (i=0; i<4; i++)
+ {
+ sprintf (p, "%4.4x ", x.s[i]);
+ p += strlen (p);
+ }
+ strcat (p, "\n");
+}
+
+int
+check (const char *input, const char *reference[])
+{
+ int broken, i, j, len;
+ const char *p_input;
+ char *p_comparison;
+ int new_errors = 0;
+
+ p_comparison = &comparison[0];
+ p_input = input;
+
+ for (i = 0; *reference[i] != '\0'; i++)
+ {
+ broken = 0;
+ len = strlen (reference[i]);
+ for (j = 0; j < len; j++)
+ {
+ /* Ignore the terminating NUL characters at the end of every string in 'reference[]'. */
+ if (!broken && *p_input != reference[i][j])
+ {
+ *p_comparison = '\0';
+ strcat (p_comparison, " >>> ");
+ p_comparison += strlen (p_comparison);
+ new_errors++;
+ broken = 1;
+ }
+ *p_comparison = *p_input;
+ p_comparison++;
+ p_input++;
+ }
+ if (broken)
+ {
+ *p_comparison = '\0';
+ strcat (p_comparison, "expected:\n");
+ strcat (p_comparison, reference[i]);
+ p_comparison += strlen (p_comparison);
+ }
+ }
+ *p_comparison = '\0';
+ strcat (p_comparison, new_errors ? "failure\n\n" : "O.K.\n\n") ;
+ errors += new_errors;
+ return 0;
+}