[PATCH 1/1] DAGCombiner: Add (A - (0-B)) -> A+B optimization
Chad Rosier
mcrosier at codeaurora.org
Tue Sep 23 12:21:46 PDT 2014
Testcase?
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
> lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> index 33e7059..bc39fe3 100644
> --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> @@ -1794,6 +1794,10 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
> // fold (A+B)-B -> A
> if (N0.getOpcode() == ISD::ADD && N0.getOperand(1) == N1)
> return N0.getOperand(0);
> + // fold (A - (0-B)) -> A+B
> + if (N1.getOpcode() == ISD::SUB && isa<ConstantSDNode>(N1.getOperand(0))
> &&
> + cast<ConstantSDNode>(N1.getOperand(0))->isNullValue())
> + return DAG.getNode(ISD::ADD, SDLoc(N), VT, N0, N1.getOperand(1));
> // fold C2-(A+C1) -> (C2-C1)-A
> if (N1.getOpcode() == ISD::ADD && N0C && N1C1) {
> SDValue NewC = DAG.getConstant(N0C->getAPIntValue() -
> N1C1->getAPIntValue(),
> --
> 1.9.3
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list