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

            Bug ID: 107647
           Summary: GCC 12.2.0 may produce FMAs even with
                    -ffp-contract=off
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bartoldeman at users dot sourceforge.net
  Target Milestone: ---

I stumped upon an example where GCC generates FMA instruction even when FMAs
are disabled using -ffp-contract=off (extracted from
https://github.com/xianyi/OpenBLAS/blob/develop/kernel/x86_64/cscal.c)

$ cat cscal.c
void cscal(int n, float da_r, float *x)
{
  for (int i = 0; i < n; i += 4)
    {
      float temp0  =  da_r * x[i]   - x[i+1];
      float temp1  =  da_r * x[i+2] - x[i+3];
      x[i+1]       =  da_r * x[i+1] + x[i];
      x[i+3]       =  da_r * x[i+3] + x[i+2];
      x[i]         =  temp0;
      x[i+2]       =  temp1;
    }
}
$ gcc -S -march=haswell -O2 -ffp-contract=off cscal.c
$ grep fma cscal.s
        vfmaddsub231ps  %xmm0, %xmm2, %xmm1

I would expect there to be no FMA instructions in there.

Reply via email to