2007-05-23 H.J. Lu <hongjiu.lu@intel.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-insertps-2.c
blobfa9e277b8ea4f1298e3951671c2eaadc695b1257
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>
9 static void
10 sse4_1_test (void)
12 union
14 __m128 x;
15 float f[4];
16 } vals[4], val;
17 int i, j;
19 val.f[0]= 1.;
20 val.f[1]= 2.;
21 val.f[2]= 3.;
22 val.f[3]= 4.;
24 vals[0].x = _MM_PICK_OUT_PS (val.x, 0);
25 vals[1].x = _MM_PICK_OUT_PS (val.x, 1);
26 vals[2].x = _MM_PICK_OUT_PS (val.x, 2);
27 vals[3].x = _MM_PICK_OUT_PS (val.x, 3);
29 for (i = 0; i < 4; i++)
30 for (j = 0; j < 4; j++)
31 if ((j != 0 && vals[i].f[j] != 0)
32 || (j == 0 && vals[i].f[j] != val.f[i]))
33 abort ();
35 if (_MM_MK_INSERTPS_NDX(0, 0, 0x1) != 0x01
36 || _MM_MK_INSERTPS_NDX(0, 1, 0x2) != 0x12
37 || _MM_MK_INSERTPS_NDX(0, 2, 0x3) != 0x23
38 || _MM_MK_INSERTPS_NDX(0, 3, 0x4) != 0x34
39 || _MM_MK_INSERTPS_NDX(1, 0, 0x5) != 0x45
40 || _MM_MK_INSERTPS_NDX(1, 1, 0x6) != 0x56
41 || _MM_MK_INSERTPS_NDX(2, 2, 0x7) != 0xA7
42 || _MM_MK_INSERTPS_NDX(3, 3, 0x8) != 0xF8)
43 abort ();