Implement the code for PowerPC/inverted-bool-compares.ll, even though it
authorChris Lattner <sabre@nondot.org>
Wed, 5 Oct 2005 06:11:08 +0000 (06:11 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 5 Oct 2005 06:11:08 +0000 (06:11 +0000)
that testcase still does not pass with the dag combiner.  This is because
not all forms of br* are folded yet.

Also, when we combine a node into another one, delete the node immediately
instead of waiting for the node to potentially come up in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23632 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 9f836733516809b7e33e21d5d25348ec647cc135..ed2af3c590b5275b7927805a3c7786b35af85b0c 100644 (file)
@@ -313,6 +313,9 @@ void DAGCombiner::Run(bool RunningAfterLegalize) {
         // Nodes can end up on the worklist more than once.  Make sure we do
         // not process a node that has been replaced.
         removeFromWorkList(N);
+        
+        // Finally, since the node is now dead, remove it from the graph.
+        DAG.DeleteNode(N);
       }
     }
   }
@@ -1546,7 +1549,7 @@ SDOperand DAGCombiner::SimplifySetCC(MVT::ValueType VT, SDOperand N0,
                                             ExtDstTy),
                             Cond);
       }
-
+      
       uint64_t MinVal, MaxVal;
       unsigned OperandBitSize = MVT::getSizeInBits(N1C->getValueType(0));
       if (ISD::isSignedIntSetCC(Cond)) {
@@ -1682,6 +1685,18 @@ SDOperand DAGCombiner::SimplifySetCC(MVT::ValueType VT, SDOperand N0,
         }
       }
 
+      // Turn (X^C1) == C2 into X == C1^C2 iff X&~C1 = 0.  Common for condcodes.
+      if (N0.getOpcode() == ISD::XOR)
+        if (ConstantSDNode *XORC = dyn_cast<ConstantSDNode>(N0.getOperand(1)))
+          if (ConstantSDNode *RHSC = dyn_cast<ConstantSDNode>(N1)) {
+            // If we know that all of the inverted bits are zero, don't bother
+            // performing the inversion.
+            if (MaskedValueIsZero(N0.getOperand(0), ~XORC->getValue(), TLI))
+              return DAG.getSetCC(VT, N0.getOperand(0),
+                              DAG.getConstant(XORC->getValue()^RHSC->getValue(),
+                                              N0.getValueType()), Cond);
+          }
+      
       // Simplify (X+Z) == X -->  Z == 0
       if (N0.getOperand(0) == N1)
         return DAG.getSetCC(VT, N0.getOperand(1),