From 498564e6fbd687efd75577caff5bcb8f71d0e1b4 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 8 Jun 2018 18:00:46 +0000 Subject: [PATCH] [DAGCombiner] clean up comments; NFC llvm-svn: 334312 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 8b7abdb0395c..00ce421e6c69 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -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);