summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2008-01-29 02:24:00 +0000
committerNate Begeman <natebegeman@mac.com>2008-01-29 02:24:00 +0000
commitef33767efb2e80e9ddadb27a958642eeea777d8a (patch)
treea9362b96418982939407289b4d9ebf528baa759b /llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
parent2b3bc3042018314cf4f8c835e2677eed4c464ea7 (diff)
downloadbcm5719-llvm-ef33767efb2e80e9ddadb27a958642eeea777d8a.tar.gz
bcm5719-llvm-ef33767efb2e80e9ddadb27a958642eeea777d8a.zip
Properly expand extract-element for non-power-of-2 codegen
llvm-svn: 46486
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 54cfad69309..d18d4d959b4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -4405,14 +4405,15 @@ SDOperand SelectionDAGLegalize::ExpandEXTRACT_VECTOR_ELT(SDOperand Op) {
// This must be an access of the only element. Return it.
Op = ScalarizeVectorOp(Vec);
} else if (!TLI.isTypeLegal(TVT) && isa<ConstantSDNode>(Idx)) {
+ unsigned NumLoElts = 1 << Log2_32(NumElems-1);
ConstantSDNode *CIdx = cast<ConstantSDNode>(Idx);
SDOperand Lo, Hi;
SplitVectorOp(Vec, Lo, Hi);
- if (CIdx->getValue() < NumElems/2) {
+ if (CIdx->getValue() < NumLoElts) {
Vec = Lo;
} else {
Vec = Hi;
- Idx = DAG.getConstant(CIdx->getValue() - NumElems/2,
+ Idx = DAG.getConstant(CIdx->getValue() - NumLoElts,
Idx.getValueType());
}
OpenPOWER on IntegriCloud