PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx-round-sfix-2-vec.c
blobdc0a7db33d885794acfee930274b815dca6cb962
1 /* { dg-do run } */
2 /* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx" } */
3 /* { dg-require-effective-target avx } */
4 /* { dg-skip-if "no M_PI" { vxworks_kernel } } */
6 #ifndef CHECK_H
7 #define CHECK_H "avx-check.h"
8 #endif
10 #ifndef TEST
11 #define TEST avx_test
12 #endif
14 #include CHECK_H
16 #define __NO_MATH_INLINES
17 #include <math.h>
19 extern double round (double);
21 #define NUM 4
23 static void
24 __attribute__((__target__("fpmath=sse")))
25 init_src (double *src)
27 int i, sign = 1;
28 double f = rand ();
30 for (i = 0; i < NUM; i++)
32 src[i] = (i + 1) * f * M_PI * sign;
33 if (i < (NUM / 2))
35 if ((i % 6) == 0)
36 f = f * src[i];
38 else if (i == (NUM / 2))
39 f = rand ();
40 else if ((i % 6) == 0)
41 f = 1 / (f * (i + 1) * src[i] * M_PI * sign);
42 sign = -sign;
46 static void
47 __attribute__((__target__("fpmath=387")))
48 TEST (void)
50 double a[NUM];
51 int r[NUM];
52 int i;
54 init_src (a);
56 for (i = 0; i < NUM; i++)
57 r[i] = (int) round (a[i]);
59 /* check results: */
60 for (i = 0; i < NUM; i++)
61 if (r[i] != (int) round (a[i]))
62 abort();