[llvm-dev] Condition code in DAGCombiner::visitFADDForFMACombine?

Ryan Taylor via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 20 09:56:29 PDT 2018


I'm curious why the condition to fuse is this:

// Floating-point multiply-add with intermediate rounding.
  bool HasFMAD = (LegalOperations && TLI.isOperationLegal(ISD::FMAD, VT));

static bool isContractable(SDNode *N) {
  SDNodeFlags F = N->getFlags();
  return F.hasAllowContract() || F.hasAllowReassociation();
}

bool CanFuse = Options.UnsafeFPMath || isContractable(N);
bool AllowFusionGlobally = (Options.AllowFPOpFusion == FPOpFusion::Fast ||
CanFuse || HasFMAD);
// If the addition is not contractable, do not combine.
if (!AllowFusionGlobally && !isContractable(N))
    return SDValue();

Specifically the AllowFusionGlobally, I would have expected something more
like:

bool AllowFusionGlobally = (Options.AllowFPOpFusion == FPOpFusion::Fast &&
CanFuse && HasFMAD);

or at the very least:

bool AllowFusionGlobally = ((Options.AllowFPOpFusion == FPOpFusion::Fast ||
CanFuse) && HasFMAD);

It seems that as long as the target can do fmad it does do fmad since
HasFMAD is true.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180820/0c041a6c/attachment-0001.html>


More information about the llvm-dev mailing list