Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.267 -> 1.268 --- Log message: Remove this xform: (shl (add x, c1), c2) -> (add (shl x, c2), c1<<c2) Replace it with: (add (shl (add x, c1), c2), ) -> (add (add (shl x, c2), c1<<c2), ) This fixes test/CodeGen/ARM/smul.ll --- Diffs of the changes: (+26 -7) DAGCombiner.cpp | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.267 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.268 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.267 Mon Jan 15 23:59:59 2007 +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Jan 19 11:51:44 2007 @@ -653,6 +653,22 @@ return Result; } +static +SDOperand combineShlAddConstant(SDOperand N0, SDOperand N1, SelectionDAG &DAG) { + MVT::ValueType VT = N0.getValueType(); + SDOperand N00 = N0.getOperand(0); + SDOperand N01 = N0.getOperand(1); + ConstantSDNode *N01C = dyn_cast<ConstantSDNode>(N01); + if (N01C && N00.getOpcode() == ISD::ADD && N00.Val->hasOneUse() && + isa<ConstantSDNode>(N00.getOperand(1))) { + N0 = DAG.getNode(ISD::ADD, VT, + DAG.getNode(ISD::SHL, VT, N00.getOperand(0), N01), + DAG.getNode(ISD::SHL, VT, N00.getOperand(1), N01)); + return DAG.getNode(ISD::ADD, VT, N0, N1); + } + return SDOperand(); +} + SDOperand DAGCombiner::visitADD(SDNode *N) { SDOperand N0 = N->getOperand(0); SDOperand N1 = N->getOperand(1); @@ -711,6 +727,16 @@ } } + // fold (add (shl (add x, c1), c2), ) -> (add (add (shl x, c2), c1<<c2), ) + if (N0.getOpcode() == ISD::SHL && N0.Val->hasOneUse()) { + SDOperand Result = combineShlAddConstant(N0, N1, DAG); + if (Result.Val) return Result; + } + if (N1.getOpcode() == ISD::SHL && N1.Val->hasOneUse()) { + SDOperand Result = combineShlAddConstant(N1, N0, DAG); + if (Result.Val) return Result; + } + return SDOperand(); } @@ -1615,13 +1641,6 @@ if (N1C && N0.getOpcode() == ISD::SRA && N1 == N0.getOperand(1)) return DAG.getNode(ISD::AND, VT, N0.getOperand(0), DAG.getConstant(~0ULL << N1C->getValue(), VT)); - // fold (shl (add x, c1), c2) -> (add (shl x, c2), c1<<c2) - if (N1C && N0.getOpcode() == ISD::ADD && N0.Val->hasOneUse() && - isa<ConstantSDNode>(N0.getOperand(1))) { - return DAG.getNode(ISD::ADD, VT, - DAG.getNode(ISD::SHL, VT, N0.getOperand(0), N1), - DAG.getNode(ISD::SHL, VT, N0.getOperand(1), N1)); - } return SDOperand(); } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits