summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2006-02-05 08:07:24 +0000
committerNate Begeman <natebegeman@mac.com>2006-02-05 08:07:24 +0000
commit3dc8b89493c4deba5f17a96772031ab370ee66b9 (patch)
tree0da9ba2c06cb5beb58b782dbdd1fe54f8f0810e3 /llvm/lib/CodeGen
parent4b8fcc229f558dd437e07945b485da3dbe1d43cb (diff)
downloadbcm5719-llvm-3dc8b89493c4deba5f17a96772031ab370ee66b9.tar.gz
bcm5719-llvm-3dc8b89493c4deba5f17a96772031ab370ee66b9.zip
fold c1 << (x + c2) into (c1 << c2) << x. fix a warning.
llvm-svn: 26005
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 533fd70de02..e853db3310a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -838,7 +838,7 @@ SDOperand DAGCombiner::visitUREM(SDNode *N) {
if (N1.getOpcode() == ISD::SHL) {
if (ConstantSDNode *SHC = dyn_cast<ConstantSDNode>(N1.getOperand(0))) {
if (isPowerOf2_64(SHC->getValue())) {
- SDOperand Add = DAG.getNode(ISD::ADD, VT, N1, DAG.getConstant(-1, VT));
+ SDOperand Add = DAG.getNode(ISD::ADD, VT, N1,DAG.getConstant(~0ULL,VT));
WorkList.push_back(Add.Val);
return DAG.getNode(ISD::AND, VT, N0, Add);
}
@@ -1288,6 +1288,12 @@ SDOperand DAGCombiner::visitSHL(SDNode *N) {
// fold (shl 0, x) -> 0
if (N0C && N0C->isNullValue())
return N0;
+ // fold (shl c1, (add x, c2)) -> (shl c1 << c2, x)
+ if (N0C && N1.getOpcode() == ISD::ADD &&
+ N1.getOperand(1).getOpcode() == ISD::Constant) {
+ SDOperand LHS = DAG.getNode(ISD::SHL, VT, N0, N1.getOperand(1));
+ return DAG.getNode(ISD::SHL, VT, LHS, N1.getOperand(0));
+ }
// fold (shl x, c >= size(x)) -> undef
if (N1C && N1C->getValue() >= OpSizeInBits)
return DAG.getNode(ISD::UNDEF, VT);
OpenPOWER on IntegriCloud