One more transformation.

llvm-svn: 60432
This commit is contained in:
Dale Johannesen 2008-12-02 18:40:40 +00:00
parent 70060013d2
commit 54bdec238a
1 changed files with 8 additions and 0 deletions

View File

@ -1025,6 +1025,14 @@ SDValue DAGCombiner::visitADD(SDNode *N) {
return DAG.getNode(ISD::SUB, VT, N1.getOperand(0),
N1.getOperand(1).getOperand(0));
}
// fold (A+((B-A)+-C)) to (B+-C)
if ((N1.getOpcode() == ISD::SUB || N1.getOpcode() == ISD::ADD) &&
N1.getOperand(0).getOpcode() == ISD::SUB &&
N0 == N1.getOperand(0).getOperand(1)) {
return DAG.getNode(N1.getOpcode(), VT, N1.getOperand(0).getOperand(0),
N1.getOperand(1));
}
// fold (A-B)+(C-D) to (A+C)-(B+D) when A or C is constant
if (N0.getOpcode() == ISD::SUB && N1.getOpcode() == ISD::SUB) {
SDValue N00 = N0.getOperand(0);