diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index bf4b39db07b..1e05d583e83 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1454,6 +1454,13 @@ SDOperand DAGCombiner::visitSHL(SDNode *N) { 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<hasOneUse() && + isa(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(); }