Another round of dag combiner changes.  This fixes some missing XOR folds
as well as fixing how we replace old values with new values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23260 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 3aaf5c6..7d9f79f 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1256,7 +1256,6 @@
   ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.Val);
   if (N1C) {
     if (N2C) {
-      if (!CombinerEnabled) {
       uint64_t C1 = N1C->getValue(), C2 = N2C->getValue();
       switch (Opcode) {
       case ISD::ADD: return getConstant(C1 + C2, VT);
@@ -1284,7 +1283,6 @@
       case ISD::SRA  : return getConstant(N1C->getSignExtended() >>(int)C2, VT);
       default: break;
       }
-      }
     } else {      // Cannonicalize constant to RHS if commutative
       if (isCommutativeBinOp(Opcode)) {
         std::swap(N1C, N2C);
@@ -1315,6 +1313,7 @@
   if (N2C) {
     uint64_t C2 = N2C->getValue();
 
+    if (!CombinerEnabled) {
     switch (Opcode) {
     case ISD::ADD:
       if (!C2) return N1;         // add X, 0 -> X
@@ -1481,6 +1480,7 @@
       }
       break;
     }
+    }
 
     // Reassociate ((X op C1) op C2) if possible.
     if (N1.getOpcode() == Opcode && isAssociativeBinOp(Opcode))
@@ -1493,7 +1493,6 @@
   ConstantFPSDNode *N2CFP = dyn_cast<ConstantFPSDNode>(N2.Val);
   if (N1CFP) {
     if (N2CFP) {
-      if (!CombinerEnabled) {
       double C1 = N1CFP->getValue(), C2 = N2CFP->getValue();
       switch (Opcode) {
       case ISD::ADD: return getConstantFP(C1 + C2, VT);
@@ -1507,7 +1506,6 @@
         break;
       default: break;
       }
-      }
     } else {      // Cannonicalize constant to RHS if commutative
       if (isCommutativeBinOp(Opcode)) {
         std::swap(N1CFP, N2CFP);
@@ -1515,9 +1513,11 @@
       }
     }
 
+    if (!CombinerEnabled) {
     if (Opcode == ISD::FP_ROUND_INREG)
       return getNode(ISD::FP_EXTEND, VT,
                      getNode(ISD::FP_ROUND, cast<VTSDNode>(N2)->getVT(), N1));
+    }
   }
 
   // Finally, fold operations that do not require constants.