diff options
author | Fiona Glaser <escha@apple.com> | 2015-06-05 17:52:34 +0000 |
---|---|---|
committer | Fiona Glaser <escha@apple.com> | 2015-06-05 17:52:34 +0000 |
commit | 666e3524407e1978743281f044dff19db3c2668a (patch) | |
tree | f470cbb0f714d59e9a08bc494185767a69eda2db /llvm/lib/CodeGen/SelectionDAG | |
parent | 4849aa35b776c0bd9591eb9b7a61f5d9748bc9ef (diff) | |
download | bcm5719-llvm-666e3524407e1978743281f044dff19db3c2668a.tar.gz bcm5719-llvm-666e3524407e1978743281f044dff19db3c2668a.zip |
DAGCombiner: don't duplicate (fmul x, c) in visitFNEG if fneg is free
For targets with a free fneg, this fold is always a net loss if it
ends up duplicating the multiply, so definitely avoid it.
This might be true for some targets without a free fneg too, but
I'll leave that for future investigation.
llvm-svn: 239167
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 0619c945fd2..d5b2f3658bc 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -8781,7 +8781,8 @@ SDValue DAGCombiner::visitFNEG(SDNode *N) { } // (fneg (fmul c, x)) -> (fmul -c, x) - if (N0.getOpcode() == ISD::FMUL) { + if (N0.getOpcode() == ISD::FMUL && + (N0.getNode()->hasOneUse() || !TLI.isFNegFree(VT))) { ConstantFPSDNode *CFP1 = dyn_cast<ConstantFPSDNode>(N0.getOperand(1)); if (CFP1) { APFloat CVal = CFP1->getValueAPF(); |