aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-01-06 01:06:31 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-01-06 01:06:31 +0000
commitda95a84a11e684072ea25fbb9830e769039fd985 (patch)
tree023a6eed0ee8c3e06bc2eaff95441d072fe9d837 /lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parenta35ef6350defdc09eb912c52603cffa6afbd78e2 (diff)
fold (shl x, 1) -> (add x, x)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25120 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 30a4c9f637..9770ae232b 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1282,6 +1282,9 @@ SDOperand DAGCombiner::visitSHL(SDNode *N) {
// fold (shl x, 0) -> x
if (N1C && N1C->isNullValue())
return N0;
+ // fold (shl x, 1) -> (add x, x)
+ if (N1C && N1C->getValue() == 1)
+ return DAG.getNode(ISD::ADD, VT, N0, N0);
// if (shl x, c) is known to be zero, return 0
if (N1C && MaskedValueIsZero(SDOperand(N, 0), ~0ULL >> (64-OpSizeInBits),TLI))
return DAG.getConstant(0, VT);