Index: lib/CodeGen/CGExprScalar.cpp =================================================================== --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -2563,22 +2563,19 @@ if (CGF.CGM.getCodeGenOpts().getFPContractMode() != CodeGenOptions::FPC_On) return nullptr; - // We have a potentially fusable op. Look for a mul on one of the operands. + // We have a potentially fusable op. Look for a mul on one of the operands + // that does not have any other uses. if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) { - if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) { - assert(LHSBinOp->getNumUses() == 0 && - "Operations with multiple uses shouldn't be contracted."); + if (LHSBinOp->getOpcode() == llvm::Instruction::FMul && + LHSBinOp->hasNUses(0)) return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub); - } - } else if (llvm::BinaryOperator* RHSBinOp = - dyn_cast(op.RHS)) { - if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) { - assert(RHSBinOp->getNumUses() == 0 && - "Operations with multiple uses shouldn't be contracted."); + } + if (llvm::BinaryOperator* RHSBinOp = dyn_cast(op.RHS)) { + if (RHSBinOp->getOpcode() == llvm::Instruction::FMul && + RHSBinOp->hasNUses(0)) return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false); - } } - + return nullptr; }