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
71
72
73
74
75
|
/* PR rtl-optimization/21239 */
/* { dg-do run } */
/* { dg-options "-O2 -msse2" } */
/* { dg-require-effective-target sse2 } */
#include "sse2-check.h"
#include <emmintrin.h>
void
foo (unsigned int x, double *y, const double *z)
{
__m128d tmp;
while (x)
{
tmp = _mm_load_sd (z);
_mm_store_sd (y, tmp);
--x; ++z; ++y;
}
}
void
bar (unsigned int x, float *y, const float *z)
{
__m128 tmp;
unsigned int i;
for (i = 0; i < x; ++i)
{
tmp = (__m128) { *z, 0, 0, 0 };
*y = __builtin_ia32_vec_ext_v4sf (tmp, 0);
++z; ++y;
}
for (i = 0; i < x; ++i)
{
tmp = (__m128) { 0, *z, 0, 0 };
*y = __builtin_ia32_vec_ext_v4sf (tmp, 1);
++z; ++y;
}
for (i = 0; i < x; ++i)
{
tmp = (__m128) { 0, 0, *z, 0 };
*y = __builtin_ia32_vec_ext_v4sf (tmp, 2);
++z; ++y;
}
for (i = 0; i < x; ++i)
{
tmp = (__m128) { 0, 0, 0, *z };
*y = __builtin_ia32_vec_ext_v4sf (tmp, 3);
++z; ++y;
}
}
static void
sse2_test (void)
{
unsigned int i;
double a[16], b[16];
float c[16], d[16];
for (i = 0; i < 16; ++i)
{
a[i] = 1;
b[i] = 2;
c[i] = 3;
d[i] = 4;
}
foo (16, a, b);
bar (4, c, d);
for (i = 0; i < 16; ++i)
{
if (a[i] != 2)
abort ();
if (c[i] != 4)
abort ();
}
}
|