diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-05-08 06:44:42 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-05-08 06:44:42 +0000 |
commit | 363160a6be82df343fa60aa09d9d8f8f44605529 (patch) | |
tree | 8385f9313f583f6f7f9bcf1d53a42ebe4475e14a /lib/CodeGen | |
parent | aa76a93cd35abd922b66825bb4e3e0b6e14ccfd5 (diff) | |
download | external_llvm-363160a6be82df343fa60aa09d9d8f8f44605529.tar.gz external_llvm-363160a6be82df343fa60aa09d9d8f8f44605529.tar.bz2 external_llvm-363160a6be82df343fa60aa09d9d8f8f44605529.zip |
DAGCombiner: Simplify inverted bit tests
Fold (xor (and x, y), y) -> (and (not x), y)
This removes an opportunity for a constant to appear twice.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181395 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 2e09ec08fd..700ee12072 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3460,6 +3460,15 @@ SDValue DAGCombiner::visitXOR(SDNode *N) { return DAG.getNode(NewOpcode, N->getDebugLoc(), VT, LHS, RHS); } } + // fold (xor (and x, y), y) -> (and (not x), y) + if (N0.getOpcode() == ISD::AND && N0.getNode()->hasOneUse() && + N0->getOperand(1) == N1) { + SDValue X = N0->getOperand(0); + SDValue NotX = DAG.getNode(ISD::XOR, X.getDebugLoc(), VT, X, + DAG.getConstant(APInt::getAllOnesValue(VT.getSizeInBits()), VT)); + AddToWorkList(NotX.getNode()); + return DAG.getNode(ISD::AND, N->getDebugLoc(), VT, NotX, N1); + } // fold (xor (xor x, c1), c2) -> (xor x, (xor c1, c2)) if (N1C && N0.getOpcode() == ISD::XOR) { ConstantSDNode *N00C = dyn_cast<ConstantSDNode>(N0.getOperand(0)); |