From 9201100b297d37b0911172a6e329415af3085bc9 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 19 Jan 2007 17:51:44 +0000 Subject: [PATCH] Remove this xform: (shl (add x, c1), c2) -> (add (shl x, c2), c1< (add (add (shl x, c2), c1<(N01); + if (N01C && N00.getOpcode() == ISD::ADD && N00.Val->hasOneUse() && + isa(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 @@ SDOperand DAGCombiner::visitADD(SDNode *N) { } } + // fold (add (shl (add x, c1), c2), ) -> (add (add (shl x, c2), c1<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 @@ 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(); }