https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107647

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to Alexander Monakov from comment #3)
> > Nice catch, thanks for the report. This is due to g:7d810646d421
> > 
> > The documentation should clarify that patterns correspond to basic fma
> > instructions (without intermediate rounding), and SLP pattern matching
> > should check flag_fp_contract_mode != FP_CONTRACT_OFF.
> 
> I don't think they should. Because __builtin_fma (and fma and fmaf) should
> be able to be used from an user program and still get FMA instructions. And
> even the SLP instruction patterns can be generating using those.

That is:
void f(float *a, float *b, float *c)
{
  float t0 = __builtin_fmaf(a[0], b[0], c[0]);
  float t1 = __builtin_fmaf(a[1], b[1], c[1]);
  a[0] = t0;
  a[1] = t1;
}
Should produce:
        vmovq   xmm0, QWORD PTR [rdi]
        vmovq   xmm2, QWORD PTR [rsi]
        vmovq   xmm1, QWORD PTR [rdx]
        vfmadd132ps     xmm0, xmm1, xmm2
        vmovlps QWORD PTR [rdi], xmm0
        ret
Even with  -ffp-contract=off -march=haswell -O3

Reply via email to