[PATCH] D26602: [DAGCombiner] do not fold (fmul (fadd X, 1), Y) -> (fmad X, Y, Y) by default

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 10:27:43 PST 2016


spatel added a comment.

In https://reviews.llvm.org/D26602#609222, @nhaehnle wrote:

> Rebased on https://reviews.llvm.org/D27260.
>
> Tentatively disable the FMAD variant unless unsafe-math is enabled. I
>  haven't yet checked/updated the tests, will follow up if the change in
>  general is agreed on.


The logic looks correct to me, but I'd change the code to make it (hopefully) clearer:

  // Floating-point multiply-add without intermediate rounding.
  bool UseFMA = (Options.UnsafeFPMath || Options.AllowFPOpFusion == FPOpFusion::Fast) && 
                                    TLI.isFMAFasterThanFMulAndFAdd(VT) &&
                                    (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::FMA, VT));
  
  // Floating-point multiply-add with intermediate rounding. This can result
  // in a less precise result due to the changed rounding order.
  bool UseFMAD = Options.UnsafeFPMath && 
                                       (LegalOperations && TLI.isOperationLegal(ISD::FMAD, VT));

Depending on the formatting, maybe that's even harder to read though...

If we can't prove that the FMA (without intermediate rounding) version is safe, then we should conservatively disable its FPOpFusion::Fast option for now.


https://reviews.llvm.org/D26602





More information about the llvm-commits mailing list