summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/arm/fp16-builtins-1.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.target/arm/fp16-builtins-1.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.target/arm/fp16-builtins-1.c')
-rw-r--r--gcc/testsuite/gcc.target/arm/fp16-builtins-1.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/arm/fp16-builtins-1.c b/gcc/testsuite/gcc.target/arm/fp16-builtins-1.c
new file mode 100644
index 000000000..868768028
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/fp16-builtins-1.c
@@ -0,0 +1,92 @@
+/* Test type-generic builtins with __fp16 arguments.
+ Except as otherwise noted, they should behave exactly
+ the same as those with float arguments. */
+
+/* { dg-do run } */
+/* { dg-options "-mfp16-format=ieee -std=gnu99" } */
+
+#include <stdlib.h>
+#include <math.h>
+
+volatile __fp16 h1, h2;
+volatile float f1, f2;
+
+void
+set1 (double x)
+{
+ h1 = x;
+ f1 = h1;
+}
+
+void
+set2 (double x, double y)
+{
+ h1 = x;
+ f1 = h1;
+ h2 = y;
+ f2 = h2;
+}
+
+#define test1(p,x) \
+ set1 (x); \
+ hp = (p (h1) ? 1 : 0); \
+ fp = (p (f1) ? 1 : 0); \
+ if (hp ^ fp) abort ()
+
+#define test2(p,x,y) \
+ set2 (x,y); \
+ hp = (p (h1, h2) ? 1 : 0); \
+ fp = (p (f1, f2) ? 1 : 0); \
+ if (hp ^ fp) abort ()
+
+int
+main (void)
+{
+ int hp, fp;
+
+ test1 (__builtin_isfinite, 17.0);
+ test1 (__builtin_isfinite, INFINITY);
+ test1 (__builtin_isinf, -0.5);
+ test1 (__builtin_isinf, INFINITY);
+ test1 (__builtin_isnan, 493.0);
+ test1 (__builtin_isnan, NAN);
+ test1 (__builtin_isnormal, 3.14159);
+
+ test2 (__builtin_isgreater, 5.0, 3.0);
+ test2 (__builtin_isgreater, 3.0, 5.0);
+ test2 (__builtin_isgreater, 73.5, 73.5);
+ test2 (__builtin_isgreater, 1.0, NAN);
+
+ test2 (__builtin_isgreaterequal, 5.0, 3.0);
+ test2 (__builtin_isgreaterequal, 3.0, 5.0);
+ test2 (__builtin_isgreaterequal, 73.5, 73.5);
+ test2 (__builtin_isgreaterequal, 1.0, NAN);
+
+ test2 (__builtin_isless, 5.0, 3.0);
+ test2 (__builtin_isless, 3.0, 5.0);
+ test2 (__builtin_isless, 73.5, 73.5);
+ test2 (__builtin_isless, 1.0, NAN);
+
+ test2 (__builtin_islessequal, 5.0, 3.0);
+ test2 (__builtin_islessequal, 3.0, 5.0);
+ test2 (__builtin_islessequal, 73.5, 73.5);
+ test2 (__builtin_islessequal, 1.0, NAN);
+
+ test2 (__builtin_islessgreater, 5.0, 3.0);
+ test2 (__builtin_islessgreater, 3.0, 5.0);
+ test2 (__builtin_islessgreater, 73.5, 73.5);
+ test2 (__builtin_islessgreater, 1.0, NAN);
+
+ test2 (__builtin_isunordered, 5.0, 3.0);
+ test2 (__builtin_isunordered, 3.0, 5.0);
+ test2 (__builtin_isunordered, 73.5, 73.5);
+ test2 (__builtin_isunordered, 1.0, NAN);
+
+ /* Test that __builtin_isnormal recognizes a denormalized __fp16 value,
+ even if it's representable as a normalized float. */
+ h1 = 5.96046E-8;
+ if (__builtin_isnormal (h1))
+ abort ();
+
+ return 0;
+}