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

            Bug ID: 65376
           Summary: LTO prevents use of fmadd
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Target: aarch64*

Take:
int main(void)
{
  return 0;
}

double f(double a, double b, double c) __attribute__((used));
double f(double a, double b, double c)
{
  return b*b+a*a;
}

--- CUT ---
Compile with -flto  -Ofast t5.c -o t6.
And then dump the resulting executable, we get:
0000000000400530 <f>:
  400530:       1e610821        fmul    d1, d1, d1
  400534:       1e600800        fmul    d0, d0, d0
  400538:       1e602820        fadd    d0, d1, d0
  40053c:       d65f03c0        ret


Without -flto we get:
0000000000400530 <f>:
  400530:       1e600800        fmul    d0, d0, d0
  400534:       1f410020        fmadd   d0, d1, d1, d0
  400538:       d65f03c0        ret


AARCH64 is just an example, it is most likely a bug everywhere.
Using -ffp-contract=fast on the command line is a workaround.

I don't know if this is a regression either.

Reply via email to