[llvm-dev] AArch64 fmul/fadd fusion

Meador Inge via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 18 21:18:49 PDT 2015


On Fri, Sep 18, 2015 at 10:34 PM, Tim Northover <t.p.northover at gmail.com> wrote:

> 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.

Sorry, sloppy language on my part.  I was aware of fmadd, but I was
really asking about turning sequences like:

  fmul s0, s0, s2
  fadd s0, s1, s0

into a fmadd:

  fmadd s0, s0, s2, s1

> 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.

Support in what way?  I don't see any patterns or machine combiners
to do the above replacement.  Did I miss something?

If I didn't miss something, is there interest in adding this to the AArch64
machine combiners assuming it was guarded by the right flag?

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

I see that on cfe-dev now.  Thanks for pointing that out.

> 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.

Agreed.

Thanks for the reply!

Cheers,

Meador


More information about the llvm-dev mailing list