PR target/80969 - Fix ICE with -mabi=ms -mavx512f, reduce wasted space when realignin...
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-rint-vec.c
blob88965a542b75a757a5f2ca8d9e2baa5af78ae4df
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 extern double rint (double);
21 #define NUM 64
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 double r[NUM];
52 int i;
54 init_src (a);
56 for (i = 0; i < NUM; i++)
57 r[i] = rint (a[i]);
59 /* check results: */
60 for (i = 0; i < NUM; i++)
61 if (r[i] != rint (a[i]))
62 abort();