2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / pr81906.c
blob6c71bec41c025eb6e3c08e905a922c7f27279872
1 /* PR target/81906 */
2 /* { dg-do run { target *-*-linux* *-*-gnu* } }
3 /* { dg-options "-O2 -frounding-math" } */
5 #include <fenv.h>
7 int
8 main ()
10 #define N 12
11 double a[N] = { 2.0, 2.25, 2.5, 2.75, 3.5, -2.0, -2.25, -2.5, -2.75, -3.5, 0x2.0p53, -0x2.0p53 };
12 double b[N], c[N], d[N], e[N];
13 double be[N] = { 2.0, 2.0, 2.0, 3.0, 4.0, -2.0, -2.0, -2.0, -3.0, -4.0, 0x2.0p53, -0x2.0p53 };
14 double ce[N] = { 2.0, 2.0, 2.0, 2.0, 3.0, -2.0, -3.0, -3.0, -3.0, -4.0, 0x2.0p53, -0x2.0p53 };
15 double de[N] = { 2.0, 3.0, 3.0, 3.0, 4.0, -2.0, -2.0, -2.0, -2.0, -3.0, 0x2.0p53, -0x2.0p53 };
16 double ee[N] = { 2.0, 2.0, 2.0, 2.0, 3.0, -2.0, -2.0, -2.0, -2.0, -3.0, 0x2.0p53, -0x2.0p53 };
17 asm volatile ("" : : "g" (a), "g" (be), "g" (ce), "g" (de), "g" (ee) : "memory");
19 int i;
20 fesetround (FE_TONEAREST);
21 for (i = 0; i < N; ++i)
22 b[i] = __builtin_rint (a[i]);
23 fesetround (FE_DOWNWARD);
24 for (i = 0; i < N; ++i)
25 c[i] = __builtin_rint (a[i]);
26 fesetround (FE_UPWARD);
27 for (i = 0; i < N; ++i)
28 d[i] = __builtin_rint (a[i]);
29 fesetround (FE_TOWARDZERO);
30 for (i = 0; i < N; ++i)
31 e[i] = __builtin_rint (a[i]);
32 fesetround (FE_TONEAREST);
33 for (i = 0; i < N; ++i)
34 if (b[i] != be[i] || c[i] != ce[i] || d[i] != de[i] || e[i] != ee[i])
35 __builtin_abort ();
36 return 0;