https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118955
Bug ID: 118955
Summary: Fortran uses vector math functions without -ffast-math
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: wilco at gcc dot gnu.org
Target Milestone: ---
This example will use the vector cosf even with -O2:
!GCC$ builtin (cosf) attributes simd (notinbranch)
PARAMETER (NX=100, G=1.4)
DIMENSION T(NX), P(NX)
INTEGER Apx
COMMON P, T
DO i = 1, 100
P(i) = COS (T(i))
ENDDO
END
GLIBC exports a special header math-vector-fortran.h which is pre-included so
that GCC knows which vector math functions are supported. Since vector
functions can have much larger ULP errors, using them by default with -O2 seems
excessive. The equivalent header for C/C++ uses the preprocessor to only
declare vector math functions when fast-math is enabled.
We could extend the syntax to do something like:
!GCC$ builtin (cosf) attributes simd (notinbranch) if (fast_math)