[ARM] Fix test armv8_2-fp16-move-1.c
[official-gcc.git] / gcc / testsuite / gcc.target / arm / fp16-builtins-1.c
blob868768028cd7e7800ed73a01535f007328ae67c0
1 /* Test type-generic builtins with __fp16 arguments.
2 Except as otherwise noted, they should behave exactly
3 the same as those with float arguments. */
5 /* { dg-do run } */
6 /* { dg-options "-mfp16-format=ieee -std=gnu99" } */
8 #include <stdlib.h>
9 #include <math.h>
11 volatile __fp16 h1, h2;
12 volatile float f1, f2;
14 void
15 set1 (double x)
17 h1 = x;
18 f1 = h1;
21 void
22 set2 (double x, double y)
24 h1 = x;
25 f1 = h1;
26 h2 = y;
27 f2 = h2;
30 #define test1(p,x) \
31 set1 (x); \
32 hp = (p (h1) ? 1 : 0); \
33 fp = (p (f1) ? 1 : 0); \
34 if (hp ^ fp) abort ()
36 #define test2(p,x,y) \
37 set2 (x,y); \
38 hp = (p (h1, h2) ? 1 : 0); \
39 fp = (p (f1, f2) ? 1 : 0); \
40 if (hp ^ fp) abort ()
42 int
43 main (void)
45 int hp, fp;
47 test1 (__builtin_isfinite, 17.0);
48 test1 (__builtin_isfinite, INFINITY);
49 test1 (__builtin_isinf, -0.5);
50 test1 (__builtin_isinf, INFINITY);
51 test1 (__builtin_isnan, 493.0);
52 test1 (__builtin_isnan, NAN);
53 test1 (__builtin_isnormal, 3.14159);
55 test2 (__builtin_isgreater, 5.0, 3.0);
56 test2 (__builtin_isgreater, 3.0, 5.0);
57 test2 (__builtin_isgreater, 73.5, 73.5);
58 test2 (__builtin_isgreater, 1.0, NAN);
60 test2 (__builtin_isgreaterequal, 5.0, 3.0);
61 test2 (__builtin_isgreaterequal, 3.0, 5.0);
62 test2 (__builtin_isgreaterequal, 73.5, 73.5);
63 test2 (__builtin_isgreaterequal, 1.0, NAN);
65 test2 (__builtin_isless, 5.0, 3.0);
66 test2 (__builtin_isless, 3.0, 5.0);
67 test2 (__builtin_isless, 73.5, 73.5);
68 test2 (__builtin_isless, 1.0, NAN);
70 test2 (__builtin_islessequal, 5.0, 3.0);
71 test2 (__builtin_islessequal, 3.0, 5.0);
72 test2 (__builtin_islessequal, 73.5, 73.5);
73 test2 (__builtin_islessequal, 1.0, NAN);
75 test2 (__builtin_islessgreater, 5.0, 3.0);
76 test2 (__builtin_islessgreater, 3.0, 5.0);
77 test2 (__builtin_islessgreater, 73.5, 73.5);
78 test2 (__builtin_islessgreater, 1.0, NAN);
80 test2 (__builtin_isunordered, 5.0, 3.0);
81 test2 (__builtin_isunordered, 3.0, 5.0);
82 test2 (__builtin_isunordered, 73.5, 73.5);
83 test2 (__builtin_isunordered, 1.0, NAN);
85 /* Test that __builtin_isnormal recognizes a denormalized __fp16 value,
86 even if it's representable as a normalized float. */
87 h1 = 5.96046E-8;
88 if (__builtin_isnormal (h1))
89 abort ();
91 return 0;