summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-05-08 06:44:42 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-05-08 06:44:42 +0000
commit386ab7f872b4bb4c42c09b47ab25fc6544466e1b (patch)
tree3d63641dc026f7e56b9292a9d4c73d057cfb96ac /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentb0b645cad157a6ee505084fcee9086c43f960fe0 (diff)
downloadbcm5719-llvm-386ab7f872b4bb4c42c09b47ab25fc6544466e1b.tar.gz
bcm5719-llvm-386ab7f872b4bb4c42c09b47ab25fc6544466e1b.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. llvm-svn: 181395
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 2e09ec08fdb..700ee12072c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/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));
OpenPOWER on IntegriCloud