aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/i386/builtin-apply-mmx.c
blob: badfe03a97dc3b0956c83811d0d7c28a21dc7499 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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 ia32 } */

#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 ();
}