summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/bfin/arith.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/bfin/arith.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/bfin/arith.c')
-rw-r--r--gcc/testsuite/gcc.target/bfin/arith.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/bfin/arith.c b/gcc/testsuite/gcc.target/bfin/arith.c
new file mode 100644
index 000000000..35029ed32
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bfin/arith.c
@@ -0,0 +1,48 @@
+extern void abort (void);
+extern void exit (int);
+
+typedef short __v2hi __attribute ((vector_size(4)));
+typedef __v2hi fract2x16;
+typedef short fract16;
+
+int main ()
+{
+ fract2x16 a, b, c, d;
+ fract16 t1, t2;
+ a = __builtin_bfin_compose_2x16 (0x3000, 0x2000);
+ b = __builtin_bfin_compose_2x16 (0x7000, 0x5000);
+ c = __builtin_bfin_compose_2x16 (0x7000, 0xc000);
+
+ d = __builtin_bfin_add_fr2x16 (a, b);
+ t1 = __builtin_bfin_extract_lo (d);
+ t2 = __builtin_bfin_extract_hi (d);
+ if (t1 != 0x7000 || t2 != 0x7fff)
+ abort ();
+
+ d = __builtin_bfin_sub_fr2x16 (a, b);
+ t1 = __builtin_bfin_extract_lo (d);
+ t2 = __builtin_bfin_extract_hi (d);
+ if (t1 != -0x3000 || t2 != -0x4000)
+ abort ();
+
+ d = __builtin_bfin_negate_fr2x16 (c);
+ t1 = __builtin_bfin_extract_lo (d);
+ t2 = __builtin_bfin_extract_hi (d);
+ if (t1 != 0x4000 || t2 != -0x7000)
+ abort ();
+
+ if (__builtin_bfin_add_fr1x32 (0x7fffffff, 1) != 0x7fffffff)
+ abort ();
+
+ if (__builtin_bfin_add_fr1x32 (0x80000000, -1) != 0x80000000)
+ abort ();
+
+ if (__builtin_bfin_add_fr1x32 (0x80000001, -1) != 0x80000000)
+ abort ();
+
+ if (__builtin_bfin_add_fr1x32 (0xFEDCBA98, 0x11111111) != 0x0FEDCBA9)
+ abort ();
+
+ exit (0);
+}
+