1 /* Test that the compiler properly optimizes floating point multiply
2 and add instructions into vfmaddss, vfmsubss, vfnmaddss,
3 vfnmsubss on FMA4 systems. */
5 /* { dg-do compile { target { ! ia32 } } } */
6 /* { dg-options "-O2 -mfma4 -mno-fma" } */
8 extern void exit (int);
11 flt_mul_add (float a
, float b
, float c
)
17 dbl_mul_add (double a
, double b
, double c
)
23 flt_mul_sub (float a
, float b
, float c
)
29 dbl_mul_sub (double a
, double b
, double c
)
35 flt_neg_mul_add (float a
, float b
, float c
)
37 return (-(a
* b
)) + c
;
41 dbl_neg_mul_add (double a
, double b
, double c
)
43 return (-(a
* b
)) + c
;
47 flt_neg_mul_sub (float a
, float b
, float c
)
49 return (-(a
* b
)) - c
;
53 dbl_neg_mul_sub (double a
, double b
, double c
)
55 return (-(a
* b
)) - c
;
58 float f
[10] = { 2, 3, 4 };
59 double d
[10] = { 2, 3, 4 };
63 f
[3] = flt_mul_add (f
[0], f
[1], f
[2]);
64 f
[4] = flt_mul_sub (f
[0], f
[1], f
[2]);
65 f
[5] = flt_neg_mul_add (f
[0], f
[1], f
[2]);
66 f
[6] = flt_neg_mul_sub (f
[0], f
[1], f
[2]);
68 d
[3] = dbl_mul_add (d
[0], d
[1], d
[2]);
69 d
[4] = dbl_mul_sub (d
[0], d
[1], d
[2]);
70 d
[5] = dbl_neg_mul_add (d
[0], d
[1], d
[2]);
71 d
[6] = dbl_neg_mul_sub (d
[0], d
[1], d
[2]);
75 /* { dg-final { scan-assembler "vfmaddss" } } */
76 /* { dg-final { scan-assembler "vfmaddsd" } } */
77 /* { dg-final { scan-assembler "vfmsubss" } } */
78 /* { dg-final { scan-assembler "vfmsubsd" } } */
79 /* { dg-final { scan-assembler "vfnmaddss" } } */
80 /* { dg-final { scan-assembler "vfnmaddsd" } } */
81 /* { dg-final { scan-assembler "vfnmsubss" } } */
82 /* { dg-final { scan-assembler "vfnmsubsd" } } */