2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-floorf-sfix-vec.c
blob7e18b46f59829375b301bd28ed9d0b26d6f889f5
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 #include <math.h>
18 #define NUM 64
20 static void
21 __attribute__((__target__("fpmath=sse")))
22 init_src (float *src)
24 int i, sign = 1;
25 float f = rand ();
27 for (i = 0; i < NUM; i++)
29 src[i] = (i + 1) * f * M_PI * sign;
30 if (i < (NUM / 2))
32 if ((i % 6) == 0)
33 f = f * src[i];
35 else if (i == (NUM / 2))
36 f = rand ();
37 else if ((i % 6) == 0)
38 f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
39 sign = -sign;
43 static void
44 __attribute__((__target__("fpmath=387")))
45 TEST (void)
47 float a[NUM];
48 int r[NUM];
49 int i;
51 init_src (a);
53 for (i = 0; i < NUM; i++)
54 r[i] = (int) __builtin_floorf (a[i]);
56 /* check results: */
57 for (i = 0; i < NUM; i++)
58 if (r[i] != (int) __builtin_floorf (a[i]))
59 abort();