https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91539
Bug ID: 91539 Summary: #pragma omp simd disables -ffp-contract=fast Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: dmatthews at utexas dot edu Target Milestone: --- When compiling this program: #include <math.h> void foo(int n, const double* restrict a, const double* restrict b, const double* restrict c, double* restrict d) { #pragma omp simd for (int i = 0;i < n;i++) d[i] = a[i]*b[i]+c[i]; } void bar(int n, const double* restrict a, const double* restrict b, const double* restrict c, double* restrict d) { #pragma omp simd for (int i = 0;i < n;i++) d[i] = fma(a[i],b[i],c[i]); } with gcc 9.2.0 and the options "-std=c99 -fopenmp-simd -O3 -march=core-avx2", the "bar" function generates FMA instructions but the "foo" function does not. Explicitly adding "-ffp-contract=fast" restores FMA in "foo". According to the documentation, "-ffp-contract=fast" should be the default, and indeed autovectorization (not using the #pragma) will generate FMA instructions without explicitly specifying this option. This issue is the same as the optimization issue reported in bug 91511, but is *not* reflected in bug 61727 of which the former is marked a duplicate.