summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-15 05:28:43 +0000
committerChris Lattner <sabre@nondot.org>2010-04-15 05:28:43 +0000
commitf9b2e3c68acb7a8188b5bd735216d207279bae9d (patch)
treeee147fd21d6a0e2c9bf2572cae1cad0b814f678c /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent9c78d63fbcc514050ea341a86f000ca1d463fbb5 (diff)
downloadbcm5719-llvm-f9b2e3c68acb7a8188b5bd735216d207279bae9d.tar.gz
bcm5719-llvm-f9b2e3c68acb7a8188b5bd735216d207279bae9d.zip
add a simple dag combine to replace trivial shl+lshr with
and. This happens with the store->load narrowing stuff. llvm-svn: 101348
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 671c5077056..5974aff03ca 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2735,6 +2735,15 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
return DAG.getNode(ISD::SRL, N->getDebugLoc(), VT, N0.getOperand(0),
DAG.getConstant(c1 + c2, N1.getValueType()));
}
+
+ // fold (srl (shl x, c), c) -> (and x, cst2)
+ if (N1C && N0.getOpcode() == ISD::SHL && N0.getOperand(1) == N1 &&
+ N0.getValueSizeInBits() <= 64) {
+ uint64_t ShAmt = N1C->getZExtValue()+64-N0.getValueSizeInBits();
+ return DAG.getNode(ISD::AND, N->getDebugLoc(), VT, N0.getOperand(0),
+ DAG.getConstant(~0ULL >> ShAmt, VT));
+ }
+
// fold (srl (anyextend x), c) -> (anyextend (srl x, c))
if (N1C && N0.getOpcode() == ISD::ANY_EXTEND) {
OpenPOWER on IntegriCloud