aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2005-10-19 00:06:56 +0000
committerNate Begeman <natebegeman@mac.com>2005-10-19 00:06:56 +0000
commit5dc897b0e4e5eb4513adc2f161412ce23f6bf2e0 (patch)
tree2832a34b29f32469c1ef114037b9b28c7dfd4b7d /lib
parentda32c9eed6743c29d219a5c3cb13788853f18016 (diff)
downloadexternal_llvm-5dc897b0e4e5eb4513adc2f161412ce23f6bf2e0.zip
external_llvm-5dc897b0e4e5eb4513adc2f161412ce23f6bf2e0.tar.gz
external_llvm-5dc897b0e4e5eb4513adc2f161412ce23f6bf2e0.tar.bz2
Teach Legalize how to do something with EXTRACT_ELEMENT when the type of
the pair of elements is a legal type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23804 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index f9703256..a065d90 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -955,14 +955,37 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
}
assert(0 && "Unreachable");
}
- case ISD::EXTRACT_ELEMENT:
- // Get both the low and high parts.
- ExpandOp(Node->getOperand(0), Tmp1, Tmp2);
- if (cast<ConstantSDNode>(Node->getOperand(1))->getValue())
- Result = Tmp2; // 1 -> Hi
- else
- Result = Tmp1; // 0 -> Lo
+ case ISD::EXTRACT_ELEMENT: {
+ MVT::ValueType OpTy = Node->getOperand(0).getValueType();
+ switch (getTypeAction(OpTy)) {
+ default:
+ assert(0 && "EXTRACT_ELEMENT action for type unimplemented!");
+ break;
+ case Legal:
+ if (cast<ConstantSDNode>(Node->getOperand(1))->getValue()) {
+ // 1 -> Hi
+ Result = DAG.getNode(ISD::SRL, OpTy, Node->getOperand(0),
+ DAG.getConstant(MVT::getSizeInBits(OpTy)/2,
+ TLI.getShiftAmountTy()));
+ Result = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0), Result);
+ } else {
+ // 0 -> Lo
+ Result = DAG.getNode(ISD::TRUNCATE, Node->getValueType(0),
+ Node->getOperand(0));
+ }
+ Result = LegalizeOp(Result);
+ break;
+ case Expand:
+ // Get both the low and high parts.
+ ExpandOp(Node->getOperand(0), Tmp1, Tmp2);
+ if (cast<ConstantSDNode>(Node->getOperand(1))->getValue())
+ Result = Tmp2; // 1 -> Hi
+ else
+ Result = Tmp1; // 0 -> Lo
+ break;
+ }
break;
+ }
case ISD::CopyToReg:
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.