summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/builtin-apply-mmx.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/i386/builtin-apply-mmx.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/i386/builtin-apply-mmx.c')
-rw-r--r--gcc/testsuite/gcc.target/i386/builtin-apply-mmx.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/builtin-apply-mmx.c b/gcc/testsuite/gcc.target/i386/builtin-apply-mmx.c
new file mode 100644
index 000000000..f6477e264
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/builtin-apply-mmx.c
@@ -0,0 +1,42 @@
+/* __builtin_apply_args () and __builtin_return () built-in functions does
+ not function properly when -mmmx is used in compile flags.
+ __builtin_apply_args () saves all registers that pass arguments to a
+ function, including %mm0-%mm3, to a memory block, and __builtin_return ()
+ restores %mm0, from a return memory block, as it can be used as a
+ function return register. Unfortunatelly, when MMX registers are touched,
+ i387 FPU switches to MMX mode, and no FP operation is possible until emms
+ instruction is issued. */
+
+/* This test case is adapted from gcc.dg/builtin-apply4.c. */
+
+/* { dg-do run { xfail { ! *-*-darwin* } } } */
+/* { dg-options "-O2 -mmmx" } */
+/* { dg-require-effective-target ilp32 } */
+
+#include "mmx-check.h"
+
+extern void abort (void);
+
+double
+foo (double arg)
+{
+ if (arg != 116.0)
+ abort ();
+
+ return arg + 1.0;
+}
+
+inline double
+bar (double arg)
+{
+ foo (arg);
+ __builtin_return (__builtin_apply ((void (*)()) foo,
+ __builtin_apply_args (), 16));
+}
+
+static void
+mmx_test (void)
+{
+ if (bar (116.0) != 117.0)
+ abort ();
+}