[PATCH] DAGCombiner: don't duplicate (fmul x, c) when folding fneg if fneg is free

escha escha at apple.com
Fri Jun 5 07:21:47 PDT 2015


Hi resistor, t.p.northover,

The fold (fneg (fmul x, c)) -> (fmul x, -c) duplicates the fmul if the fmul has multiple uses. If fneg is free, this is even worse, since we didn't actually gain anything by doing so. Check hasOneUse or fneg not being free before doing this fold.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D10277

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8781,7 +8781,8 @@
   }
 
   // (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();

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10277.27200.patch
Type: text/x-patch
Size: 549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150605/45aa135d/attachment.bin>


More information about the llvm-commits mailing list