[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / sse4_1-phminposuw.c
blob150a8a0f5638103d38a3d27d60f94129b3ab268b
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mvsx -Wno-psabi" } */
3 /* { dg-require-effective-target vsx_hw } */
5 #define NO_WARN_X86_INTRINSICS 1
6 #ifndef CHECK_H
7 #define CHECK_H "sse4_1-check.h"
8 #endif
10 #ifndef TEST
11 #define TEST sse4_1_test
12 #endif
14 #include CHECK_H
16 #include <smmintrin.h>
18 #define DIM(a) (sizeof (a) / sizeof (a)[0])
20 static void
21 TEST (void)
23 union
25 __m128i x;
26 unsigned short s[8];
27 } src[] =
29 { .s = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 } },
30 { .s = { 0x0000, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 } },
31 { .s = { 0xffff, 0xffff, 0x0000, 0xffff, 0xffff, 0xffff, 0x0000, 0xffff } },
32 { .s = { 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008 } },
33 { .s = { 0x0008, 0x0007, 0x0006, 0x0005, 0x0004, 0x0003, 0x0002, 0x0001 } },
34 { .s = { 0xfff4, 0xfff3, 0xfff2, 0xfff1, 0xfff3, 0xfff1, 0xfff2, 0xfff3 } }
36 unsigned short minVal[DIM (src)];
37 int minInd[DIM (src)];
38 unsigned short minValScalar, minIndScalar;
39 int i, j;
40 union
42 int si;
43 unsigned short s[2];
44 } res;
46 for (i = 0; i < DIM (src); i++)
48 res.si = _mm_cvtsi128_si32 (_mm_minpos_epu16 (src[i].x));
49 minVal[i] = res.s[0];
50 minInd[i] = res.s[1] & 0b111;
53 for (i = 0; i < DIM (src); i++)
55 minValScalar = src[i].s[0];
56 minIndScalar = 0;
58 for (j = 1; j < 8; j++)
59 if (minValScalar > src[i].s[j])
61 minValScalar = src[i].s[j];
62 minIndScalar = j;
65 if (minValScalar != minVal[i] && minIndScalar != minInd[i])
66 abort ();