[Bug c/20785] Pragma STDC * (C99 FP) unimplemented

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 21 10:43:00 GMT 2020


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

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note fixin(In reply to Vincent Lefèvre from comment #8)
> Concerning the STDC FP_CONTRACT pragma, implementing it would not be
> sufficient. GCC would also need to restrict how it does contraction, as it
> currently does not contract only expressions, but also sequences of
> expressions, which is invalid. Example:
> 
> double foo (double a, double b, double c)
> {
>   double p = a * b;
>   return p + c;
> }
> 
> Since a * b and p + c are separate expressions, contraction to FMA must not
> be done according to the C standard. But when contraction is allowed, GCC
> generates a FMA on my x86_64 processor:
> 
>         .cfi_startproc
>         vfmadd132sd     %xmm1, %xmm2, %xmm0
>         ret
>         .cfi_endproc

Note fixing that is as easy as wrapping FP expressions in PAREN_EXPR to
denote which ones are separate.  PAREN_EXPRs also serve as association
barriers and the FE needs to decide what FP optimization flag elides
them where exactly (the middle-end leaves them in place even with
-ffast-math).


More information about the Gcc-bugs mailing list