OSDN Git Service

* gcc.target/sh/mfmovd.c: Extend list of supported targets.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / powerpc / ppc-fma-3.c
1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
3 /* { dg-require-effective-target powerpc_altivec_ok } */
4 /* { dg-options "-O3 -ftree-vectorize -mcpu=power6 -maltivec -ffast-math" } */
5 /* { dg-final { scan-assembler-times "vmaddfp" 2 } } */
6 /* { dg-final { scan-assembler-times "fmadd " 2 } } */
7 /* { dg-final { scan-assembler-times "fmadds" 2 } } */
8 /* { dg-final { scan-assembler-times "fmsub " 1 } } */
9 /* { dg-final { scan-assembler-times "fmsubs" 1 } } */
10 /* { dg-final { scan-assembler-times "fnmadd " 1 } } */
11 /* { dg-final { scan-assembler-times "fnmadds" 1 } } */
12 /* { dg-final { scan-assembler-times "fnmsub " 1 } } */
13 /* { dg-final { scan-assembler-times "fnmsubs" 1 } } */
14
15 /* All functions should generate an appropriate (a * b) + c instruction
16    since -mfused-madd is on by default.  */
17
18 double
19 builtin_fma (double b, double c, double d)
20 {
21   return __builtin_fma (b, c, d);                       /* fmadd */
22 }
23
24 double
25 builtin_fms (double b, double c, double d)
26 {
27   return __builtin_fma (b, c, -d);                      /* fmsub */
28 }
29
30 double
31 builtin_fnma (double b, double c, double d)
32 {
33   return - __builtin_fma (b, c, d);                     /* fnmadd */
34 }
35
36 double
37 builtin_fnms (double b, double c, double d)
38 {
39   return - __builtin_fma (b, c, -d);                    /* fnmsub */
40 }
41
42 float
43 builtin_fmaf (float b, float c, float d)
44 {
45   return __builtin_fmaf (b, c, d);                      /* fmadds */
46 }
47
48 float
49 builtin_fmsf (float b, float c, float d)
50 {
51   return __builtin_fmaf (b, c, -d);                     /* fmsubs */
52 }
53
54 float
55 builtin_fnmaf (float b, float c, float d)
56 {
57   return - __builtin_fmaf (b, c, d);                    /* fnmadds */
58 }
59
60 float
61 builtin_fnmsf (float b, float c, float d)
62 {
63   return - __builtin_fmaf (b, c, -d);                   /* fnmsubs */
64 }
65
66 double
67 normal_fma (double b, double c, double d)
68 {
69   return (b * c) + d;                                   /* fmadd */
70 }
71
72 float
73 normal_fmaf (float b, float c, float d)
74 {
75   return (b * c) + d;                                   /* fmadds */
76 }
77
78 #ifndef SIZE
79 #define SIZE 1024
80 #endif
81
82 float vfa[SIZE] __attribute__((__aligned__(32)));
83 float vfb[SIZE] __attribute__((__aligned__(32)));
84 float vfc[SIZE] __attribute__((__aligned__(32)));
85 float vfd[SIZE] __attribute__((__aligned__(32)));
86
87 void
88 vector_fmaf (void)
89 {
90   int i;
91
92   for (i = 0; i < SIZE; i++)
93     vfa[i] = __builtin_fmaf (vfb[i], vfc[i], vfd[i]);   /* vaddfp */
94 }
95
96 void
97 vnormal_fmaf (void)
98 {
99   int i;
100
101   for (i = 0; i < SIZE; i++)
102     vfa[i] = (vfb[i] * vfc[i]) + vfd[i];                /* vaddfp */
103 }