[llvm-dev] AArch64 fmul/fadd fusion

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 18 20:34:13 PDT 2015


On 18 September 2015 at 20:14, Meador Inge via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Recently I was doing some AArch64 work and noticed some cases where
> fmuls were not getting fused with fadds.  Is there any particular
> reason that the AArch64 machine combiner doesn't do this like it does
> for add/mul?

AArch64's fmadd instruction is fused, which means it can produce a
different result to the two operations executed separately. The C and
C++ standards do not allow such changes.

We support them via various flags (-ffast-math is the obvious one,
though an argument could be made for supporting -mfused-madd and
-mnofused-madd as well). But in the backend we definitely have to
check *somthing* before doing the substitution.

> I am happy to work up a patch for this, but I wanted to make sure that
> there wasn't a good reason for it not already being there.  FWIW, I
> see where GCC is doing this optimization.

You might want to get together with Ana Pazos, who just asked similar
questions today.

Personally, I'd be sad to see Clang's default execution become less
conforming to the standard. But it's pretty undeniable that
"-std=gnu99/gnu11/..." do allow it by default.

Cheers.

Tim.


More information about the llvm-dev mailing list