[PATCH] D28448: InstCombine: Do unsafe math combine of fadd + fmuladd + fmul

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 11:01:45 PST 2017


hfinkel added a comment.

In https://reviews.llvm.org/D28448#673675, @arsenm wrote:

> In https://reviews.llvm.org/D28448#673662, @hfinkel wrote:
>
> > Under what circumstances do we create a 'fast' fmuladd. Maybe we should canonicalize a 'fast' fmuladd into a 'fast' mul and a 'fast' add instead?
>
>
> Clang emits this for a * b  + c with  -ffast-math -ffp-contract=on


Interesting. As implemented -ffast-math implies -ffp-contract=fast:

  const TargetOptions &Options = DAG.getTarget().Options;
  bool AllowFusion =
      (Options.AllowFPOpFusion == FPOpFusion::Fast || Options.UnsafeFPMath);

I think that we should:

1. Have -ffast-math imply -ffp-contract=fast in Clang.

and/or

2. Canonicalize fast fmuladd into fast mul + fast add.


https://reviews.llvm.org/D28448





More information about the llvm-commits mailing list