From: Chris Lattner Date: Sat, 4 Mar 2006 23:33:26 +0000 (+0000) Subject: fold (mul (add x, c1), c2) -> (add (mul x, c2), c1*c2) X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a1deca3cd62963c1f5a7c48e7e5e67fec9beadaa;p=oota-llvm.git fold (mul (add x, c1), c2) -> (add (mul x, c2), c1*c2) fold (shl (add x, c1), c2) -> (add (shl x, c2), c1< (add (mul x, c2), c1*c2) + if (N1C && N0.getOpcode() == ISD::ADD && N0.Val->hasOneUse() && + isa(N0.getOperand(1))) { + return DAG.getNode(ISD::ADD, VT, + DAG.getNode(ISD::MUL, VT, N0.getOperand(0), N1), + DAG.getNode(ISD::MUL, VT, N0.getOperand(1), N1)); + } // reassociate mul SDOperand RMUL = ReassociateOps(ISD::MUL, N0, N1); @@ -1446,6 +1452,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(); }