1 /* Test that the compiler properly optimizes floating point multiply and add
2 instructions vector into vfmaddps on FMA4 systems. */
4 /* { dg-do compile { target { ! ia32 } } } */
5 /* { dg-options "-O2 -mfma4 -ftree-vectorize -mtune=generic -mno-fma" } */
7 extern void exit (int);
9 typedef float __m128
__attribute__ ((__vector_size__ (16), __may_alias__
));
10 typedef double __m128d
__attribute__ ((__vector_size__ (16), __may_alias__
));
26 for (i
= 0; i
< SIZE
; i
++)
27 a
.f
[i
] = (b
.f
[i
] * c
.f
[i
]) + d
.f
[i
];
35 for (i
= 0; i
< SIZE
; i
++)
36 a
.d
[i
] = (b
.d
[i
] * c
.d
[i
]) + d
.d
[i
];
44 for (i
= 0; i
< SIZE
; i
++)
45 a
.f
[i
] = (b
.f
[i
] * c
.f
[i
]) - d
.f
[i
];
53 for (i
= 0; i
< SIZE
; i
++)
54 a
.d
[i
] = (b
.d
[i
] * c
.d
[i
]) - d
.d
[i
];
58 flt_neg_mul_add (void)
62 for (i
= 0; i
< SIZE
; i
++)
63 a
.f
[i
] = (-(b
.f
[i
] * c
.f
[i
])) + d
.f
[i
];
67 dbl_neg_mul_add (void)
71 for (i
= 0; i
< SIZE
; i
++)
72 a
.d
[i
] = (-(b
.d
[i
] * c
.d
[i
])) + d
.d
[i
];
87 /* { dg-final { scan-assembler "vfmaddps" } } */
88 /* { dg-final { scan-assembler "vfmaddpd" } } */
89 /* { dg-final { scan-assembler "vfmsubps" } } */
90 /* { dg-final { scan-assembler "vfmsubpd" } } */
91 /* { dg-final { scan-assembler "vfnmaddps" } } */
92 /* { dg-final { scan-assembler "vfnmaddpd" } } */