[PATCH] D14891: Replace assert with early-out in tryEmitFMulAdd
Steve Canon via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 20 15:49:07 PST 2015
scanon created this revision.
scanon added reviewers: hfinkel, resistor, lhames.
scanon added a subscriber: cfe-commits.
r253269 exposed a pre-existing issue in tryEmitFMulAdd, where we would assert if a fusable operation had operands with multiple uses (we didn't see it previously because FP_CONTRACT was off by default). Fix this issue by changing the assert into an early-out where we simply won't try to fuse.
Once this is done, we can try again at enabling FP_CONTRACT ON as a default.
http://reviews.llvm.org/D14891
Files:
lib/CodeGen/CGExprScalar.cpp
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<llvm::BinaryOperator>(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<llvm::BinaryOperator>(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<llvm::BinaryOperator>(op.RHS)) {
+ if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+ RHSBinOp->hasNUses(0))
return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
- }
}
-
+
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14891.40840.patch
Type: text/x-patch
Size: 1509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151120/50068051/attachment.bin>
More information about the cfe-commits
mailing list