From 5c46f74ec78e73bc91785299a6877f45a7b2f1df Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 5 Oct 2005 06:11:08 +0000 Subject: [PATCH] Implement the code for PowerPC/inverted-bool-compares.ll, even though it 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 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 9f836733516..ed2af3c590b 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -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(N0.getOperand(1))) + if (ConstantSDNode *RHSC = dyn_cast(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),