2007-05-22 H.J. Lu <hongjiu.lu@intel.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-dpps-2.c
blob1c9a7c9342e76eed94737f2fefd5da6f19949019
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O2 -msse4.1" } */
5 #include "sse4_1-check.h"
7 #include <smmintrin.h>
8 #include <string.h>
10 #define lmskN 0x00
11 #define lmsk0 0x01
12 #define lmsk1 0x02
13 #define lmsk2 0x04
14 #define lmsk3 0x08
15 #define lmsk01 0x03
16 #define lmsk02 0x05
17 #define lmsk03 0x09
18 #define lmsk12 0x06
19 #define lmsk13 0x0A
20 #define lmsk23 0x0C
21 #define lmskA 0x0F
23 #define hmskN 0x00
24 #define hmskA 0xF0
25 #define hmsk0 0x10
26 #define hmsk1 0x20
27 #define hmsk2 0x40
28 #define hmsk3 0x80
29 #define hmsk01 0x30
30 #define hmsk02 0x50
31 #define hmsk03 0x90
32 #define hmsk12 0x60
33 #define hmsk13 0xA0
34 #define hmsk23 0xC0
36 #ifndef HIMASK
37 #define HIMASK hmskA
38 #endif
40 #ifndef LOMASK
41 #define LOMASK lmskA
42 #endif
44 static void
45 sse4_1_test (void)
47 union
49 __m128 x;
50 float f[4];
51 } val1[16], val2[16], res[16], chk[16];
52 int i,j;
53 float tmp;
55 for (i = 0; i < 16; i++)
57 val1[i].f[0] = 2.;
58 val1[i].f[1] = 3.;
59 val1[i].f[2] = 4.;
60 val1[i].f[3] = 5.;
62 val2[i].f[0] = 10.;
63 val2[i].f[1] = 100.;
64 val2[i].f[2] = 1000.;
65 val2[i].f[3] = 10000.;
67 tmp = 0.;
68 for (j = 0; j < 4; j++)
69 if ((HIMASK & (0x10 << j)))
70 tmp += val1[i].f [j] * val2[i].f [j];
72 for (j = 0; j < 4; j++)
73 if ((LOMASK & (1 << j)))
74 chk[i].f[j] = tmp;
77 for (i = 0; i < 16; i++)
79 res[i].x = _mm_dp_ps (val1[i].x, val2[i].x, HIMASK | LOMASK);
80 if (memcmp (&res[i], &chk[i], sizeof (chk[i])))
81 abort ();