Return "(c1 + c2)" instead of yet another ADD node (which made this a

no-op).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46922 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2008-02-10 08:10:24 +00:00
parent acce85def4
commit 91b9ad1824

View File

@ -923,7 +923,7 @@ SDOperand DAGCombiner::visitADD(SDNode *N) {
return N1;
// fold (add c1, c2) -> c1+c2
if (N0C && N1C)
return DAG.getNode(ISD::ADD, VT, N0, N1);
return DAG.getConstant(N0C->getValue() + N1C->getValue(), VT);
// canonicalize constant to RHS
if (N0C && !N1C)
return DAG.getNode(ISD::ADD, VT, N1, N0);