summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-19 05:02:39 +0000
committerChris Lattner <sabre@nondot.org>2006-09-19 05:02:39 +0000
commit5a42ebcff3055930fed4a76f45127553e71c8e0a (patch)
tree259012579e74feeed84f5c48270fbfd7f8a356e2 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent4c059f496281cb03fefcc6f9f93cdaf8dcc31377 (diff)
downloadbcm5719-llvm-5a42ebcff3055930fed4a76f45127553e71c8e0a.tar.gz
bcm5719-llvm-5a42ebcff3055930fed4a76f45127553e71c8e0a.zip
Fold extract_element(cst) to cst
llvm-svn: 30478
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 55b128f515d..c310ac7faea 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1330,12 +1330,18 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
break;
}
case ISD::EXTRACT_ELEMENT:
+ assert(N2C && (unsigned)N2C->getValue() < 2 && "Bad EXTRACT_ELEMENT!");
+
// EXTRACT_ELEMENT of BUILD_PAIR is often formed while legalize is expanding
// 64-bit integers into 32-bit parts. Instead of building the extract of
// the BUILD_PAIR, only to have legalize rip it apart, just do it now.
- if (N2C && N1.getOpcode() == ISD::BUILD_PAIR) {
- assert((unsigned)N2C->getValue() < 2 && "Bad EXTRACT_ELEMENT!");
+ if (N1.getOpcode() == ISD::BUILD_PAIR)
return N1.getOperand(N2C->getValue());
+
+ // EXTRACT_ELEMENT of a constant int is also very common.
+ if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N1)) {
+ unsigned Shift = MVT::getSizeInBits(VT) * N2C->getValue();
+ return getConstant(C->getValue() >> Shift, VT);
}
break;
OpenPOWER on IntegriCloud