[llvm] r334312 - [DAGCombiner] clean up comments; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 8 11:00:46 PDT 2018


Author: spatel
Date: Fri Jun  8 11:00:46 2018
New Revision: 334312

URL: http://llvm.org/viewvc/llvm-project?rev=334312&view=rev
Log:
[DAGCombiner] clean up comments; NFC

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=334312&r1=334311&r2=334312&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Jun  8 11:00:46 2018
@@ -10507,7 +10507,7 @@ SDValue DAGCombiner::visitFMUL(SDNode *N
     if (N1CFP && N1CFP->isZero())
       return N1;
 
-    // fold (fmul (fmul x, c1), c2) -> (fmul x, (fmul c1, c2))
+    // fmul (fmul X, C1), X2 -> fmul X, C1 * C2
     if (N0.getOpcode() == ISD::FMUL) {
       // Fold scalars or any vector constants (not just splats).
       // This fold is done in general by InstCombine, but extra fmul insts
@@ -10531,13 +10531,10 @@ SDValue DAGCombiner::visitFMUL(SDNode *N
       }
     }
 
-    // fold (fmul (fadd x, x), c) -> (fmul x, (fmul 2.0, c))
-    // Undo the fmul 2.0, x -> fadd x, x transformation, since if it occurs
-    // during an early run of DAGCombiner can prevent folding with fmuls
-    // inserted during lowering.
-    if (N0.getOpcode() == ISD::FADD &&
-        (N0.getOperand(0) == N0.getOperand(1)) &&
-        N0.hasOneUse()) {
+    // Match a special-case: we convert X * 2.0 into fadd.
+    // fmul (fadd X, X), C -> fmul X, 2.0 * C
+    if (N0.getOpcode() == ISD::FADD && N0.hasOneUse() &&
+        N0.getOperand(0) == N0.getOperand(1)) {
       const SDValue Two = DAG.getConstantFP(2.0, DL, VT);
       SDValue MulConsts = DAG.getNode(ISD::FMUL, DL, VT, Two, N1, Flags);
       return DAG.getNode(ISD::FMUL, DL, VT, N0.getOperand(0), MulConsts, Flags);




More information about the llvm-commits mailing list