Update concepts branch to revision 131834
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-phminposuw.c
blob24fdf2af160d0fe454b2fec08aafa3d7dc5be00f
1 /* { dg-do run } */
2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O2 -msse4.1" } */
5 #include "sse4_1-check.h"
7 #include <smmintrin.h>
9 #define NUM 64
11 static void
12 sse4_1_test (void)
14 union
16 __m128i x[NUM/8];
17 unsigned short s[NUM];
18 } src;
19 unsigned short minVal[NUM/8];
20 int minInd[NUM/8];
21 unsigned short minValScalar, minIndScalar;
22 int i, j, res;
24 for (i = 0; i < NUM; i++)
25 src.s[i] = i * i / (i + i / 3.14 + 1.0);
27 for (i = 0, j = 0; i < NUM; i += 8, j++)
29 res = _mm_cvtsi128_si32 (_mm_minpos_epu16 (src.x [i/8]));
30 minVal[j] = res & 0xffff;
31 minInd[j] = (res >> 16) & 0x3;
34 for (i = 0; i < NUM; i += 8)
36 minValScalar = src.s[i];
37 minIndScalar = 0;
39 for (j = i + 1; j < i + 8; j++)
40 if (minValScalar > src.s[j])
42 minValScalar = src.s[j];
43 minIndScalar = j - i;
46 if (minValScalar != minVal[i/8] && minIndScalar != minInd[i/8])
47 abort ();