2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-floorf-sfix-vec.c
blobbf05af3e2811d9a9e28e3f73df842a9270f3cf8a
1 /* { dg-do run } */
2 /* { dg-options "-O2 -ffast-math -ftree-vectorize -msse4.1" } */
3 /* { dg-require-effective-target sse4 } */
4 /* { dg-skip-if "no M_PI" { vxworks_kernel } } */
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 #define __NO_MATH_INLINES
17 #include <math.h>
19 #define NUM 64
21 static void
22 __attribute__((__target__("fpmath=sse")))
23 init_src (float *src)
25 int i, sign = 1;
26 float f = rand ();
28 for (i = 0; i < NUM; i++)
30 src[i] = (i + 1) * f * M_PI * sign;
31 if (i < (NUM / 2))
33 if ((i % 6) == 0)
34 f = f * src[i];
36 else if (i == (NUM / 2))
37 f = rand ();
38 else if ((i % 6) == 0)
39 f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
40 sign = -sign;
44 static void
45 __attribute__((__target__("fpmath=387")))
46 TEST (void)
48 float a[NUM];
49 int r[NUM];
50 int i;
52 init_src (a);
54 for (i = 0; i < NUM; i++)
55 r[i] = (int) __builtin_floorf (a[i]);
57 /* check results: */
58 for (i = 0; i < NUM; i++)
59 if (r[i] != (int) __builtin_floorf (a[i]))
60 abort();