1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/* { dg-do run } */
/* { dg-options "-O2 -msse2" } */
/* { dg-require-effective-target sse2 } */
#include "sse2-check.h"
#include <emmintrin.h>
#include <string.h>
static void
sse2_test (void)
{
union
{
__m128i x;
char c[16];
short s[8];
int i[4];
long long ll[2];
} val1, res[16], tmp;
short ins[8] = { 8, 5, 9, 4, 2, 6, 1, 20 };
int masks[8];
int i;
for (i = 0; i < 16; i++)
val1.c[i] = i;
res[0].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[0], 0);
res[1].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[0], 1);
res[2].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[0], 2);
res[3].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[0], 3);
res[4].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[0], 4);
res[5].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[0], 5);
res[6].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[0], 6);
res[7].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[0], 7);
for (i = 0; i < 8; i++)
masks[i] = i;
for (i = 0; i < 8; i++)
{
tmp.x = val1.x;
tmp.s[masks[i]] = ins[0];
if (memcmp (&tmp, &res[i], sizeof (tmp)))
abort ();
}
for (i = 0; i < 8; i++)
{
res[i].x = (__m128i) __builtin_ia32_vec_set_v8hi ((__v8hi)val1.x,
ins[i], 0);
masks[i] = 0;
}
for (i = 0; i < 8; i++)
{
tmp.x = val1.x;
tmp.s[masks[i]] = ins[i];
if (memcmp (&tmp, &res[i], sizeof (tmp)))
abort ();
}
}
|