aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-19 17:29:49 +0000
committerChris Lattner <sabre@nondot.org>2005-01-19 17:29:49 +0000
commit88218ef706ba6fffc3b3f3c894910eea0f59abb1 (patch)
treebc89d71f6389dbd9448a93dab8905d5fd02883b6 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parentc3c021bcadd580a0764e12527f58a94389ae81ce (diff)
Know some simple identities. This improves codegen for (1LL << N).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 3da2f5fe7a..3b106d192d 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -615,6 +615,19 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
std::swap(N1, N2);
}
}
+
+ switch (Opcode) {
+ default: break;
+ case ISD::SHL: // shl 0, X -> 0
+ if (N1C->isNullValue()) return N1;
+ break;
+ case ISD::SRL: // srl 0, X -> 0
+ if (N1C->isNullValue()) return N1;
+ break;
+ case ISD::SRA: // sra -1, X -> -1
+ if (N1C->isAllOnesValue()) return N1;
+ break;
+ }
}
if (N2C) {