/* { dg-do run } */
|
/* { dg-do run } */
|
/* { dg-options "-O2 -msse" } */
|
/* { dg-options "-O2 -msse" } */
|
/* { dg-require-effective-target sse } */
|
/* { dg-require-effective-target sse } */
|
|
|
#include "sse-check.h"
|
#include "sse-check.h"
|
|
|
#include <xmmintrin.h>
|
#include <xmmintrin.h>
|
#include <string.h>
|
#include <string.h>
|
|
|
#define SHIFT (4)
|
#define SHIFT (4)
|
|
|
typedef union {
|
typedef union {
|
__m64 v;
|
__m64 v;
|
unsigned char c[8];
|
unsigned char c[8];
|
unsigned short int s[4];
|
unsigned short int s[4];
|
unsigned long long t;
|
unsigned long long t;
|
unsigned int u[2];
|
unsigned int u[2];
|
}vecInWord;
|
}vecInWord;
|
|
|
void sse_tests (void) __attribute__((noinline));
|
void sse_tests (void) __attribute__((noinline));
|
void dump64_16 (char *, char *, vecInWord);
|
void dump64_16 (char *, char *, vecInWord);
|
int check (const char *, const char *[]);
|
int check (const char *, const char *[]);
|
|
|
char buf[8000];
|
char buf[8000];
|
char comparison[8000];
|
char comparison[8000];
|
static int errors = 0;
|
static int errors = 0;
|
|
|
vecInWord c64, e64;
|
vecInWord c64, e64;
|
__m64 m64_64;
|
__m64 m64_64;
|
|
|
const char *reference_sse[] = {
|
const char *reference_sse[] = {
|
"_mm_shuffle_pi16 0123 4567 89ab cdef \n",
|
"_mm_shuffle_pi16 0123 4567 89ab cdef \n",
|
""
|
""
|
};
|
};
|
|
|
static void
|
static void
|
sse_test (void)
|
sse_test (void)
|
{
|
{
|
e64.t = 0x0123456789abcdefULL;
|
e64.t = 0x0123456789abcdefULL;
|
|
|
m64_64 = e64.v;
|
m64_64 = e64.v;
|
|
|
sse_tests();
|
sse_tests();
|
check (buf, reference_sse);
|
check (buf, reference_sse);
|
#ifdef DEBUG
|
#ifdef DEBUG
|
printf ("sse testing:\n");
|
printf ("sse testing:\n");
|
printf (buf);
|
printf (buf);
|
printf ("\ncomparison:\n");
|
printf ("\ncomparison:\n");
|
printf (comparison);
|
printf (comparison);
|
#endif
|
#endif
|
buf[0] = '\0';
|
buf[0] = '\0';
|
|
|
if (errors != 0)
|
if (errors != 0)
|
abort ();
|
abort ();
|
}
|
}
|
|
|
void __attribute__((noinline))
|
void __attribute__((noinline))
|
sse_tests (void)
|
sse_tests (void)
|
{
|
{
|
/* pshufw */
|
/* pshufw */
|
c64.v = _mm_shuffle_pi16 (m64_64, 0x1b);
|
c64.v = _mm_shuffle_pi16 (m64_64, 0x1b);
|
dump64_16 (buf, "_mm_shuffle_pi16", c64);
|
dump64_16 (buf, "_mm_shuffle_pi16", c64);
|
}
|
}
|
|
|
void
|
void
|
dump64_16 (char *buf, char *name, vecInWord x)
|
dump64_16 (char *buf, char *name, vecInWord x)
|
{
|
{
|
int i;
|
int i;
|
char *p = buf + strlen (buf);
|
char *p = buf + strlen (buf);
|
|
|
sprintf (p, "%s ", name);
|
sprintf (p, "%s ", name);
|
p += strlen (p);
|
p += strlen (p);
|
|
|
for (i=0; i<4; i++)
|
for (i=0; i<4; i++)
|
{
|
{
|
sprintf (p, "%4.4x ", x.s[i]);
|
sprintf (p, "%4.4x ", x.s[i]);
|
p += strlen (p);
|
p += strlen (p);
|
}
|
}
|
strcat (p, "\n");
|
strcat (p, "\n");
|
}
|
}
|
|
|
int
|
int
|
check (const char *input, const char *reference[])
|
check (const char *input, const char *reference[])
|
{
|
{
|
int broken, i, j, len;
|
int broken, i, j, len;
|
const char *p_input;
|
const char *p_input;
|
char *p_comparison;
|
char *p_comparison;
|
int new_errors = 0;
|
int new_errors = 0;
|
|
|
p_comparison = &comparison[0];
|
p_comparison = &comparison[0];
|
p_input = input;
|
p_input = input;
|
|
|
for (i = 0; *reference[i] != '\0'; i++)
|
for (i = 0; *reference[i] != '\0'; i++)
|
{
|
{
|
broken = 0;
|
broken = 0;
|
len = strlen (reference[i]);
|
len = strlen (reference[i]);
|
for (j = 0; j < len; j++)
|
for (j = 0; j < len; j++)
|
{
|
{
|
/* Ignore the terminating NUL characters at the end of every string in 'reference[]'. */
|
/* Ignore the terminating NUL characters at the end of every string in 'reference[]'. */
|
if (!broken && *p_input != reference[i][j])
|
if (!broken && *p_input != reference[i][j])
|
{
|
{
|
*p_comparison = '\0';
|
*p_comparison = '\0';
|
strcat (p_comparison, " >>> ");
|
strcat (p_comparison, " >>> ");
|
p_comparison += strlen (p_comparison);
|
p_comparison += strlen (p_comparison);
|
new_errors++;
|
new_errors++;
|
broken = 1;
|
broken = 1;
|
}
|
}
|
*p_comparison = *p_input;
|
*p_comparison = *p_input;
|
p_comparison++;
|
p_comparison++;
|
p_input++;
|
p_input++;
|
}
|
}
|
if (broken)
|
if (broken)
|
{
|
{
|
*p_comparison = '\0';
|
*p_comparison = '\0';
|
strcat (p_comparison, "expected:\n");
|
strcat (p_comparison, "expected:\n");
|
strcat (p_comparison, reference[i]);
|
strcat (p_comparison, reference[i]);
|
p_comparison += strlen (p_comparison);
|
p_comparison += strlen (p_comparison);
|
}
|
}
|
}
|
}
|
*p_comparison = '\0';
|
*p_comparison = '\0';
|
strcat (p_comparison, new_errors ? "failure\n\n" : "O.K.\n\n") ;
|
strcat (p_comparison, new_errors ? "failure\n\n" : "O.K.\n\n") ;
|
errors += new_errors;
|
errors += new_errors;
|
return 0;
|
return 0;
|
}
|
}
|
|
|