From: Nate Begeman Date: Tue, 29 Jan 2008 02:24:00 +0000 (+0000) Subject: Properly expand extract-element for non-power-of-2 codegen X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=55030dc460ff43f382abcc977b3e45bab7d87826;p=oota-llvm.git Properly expand extract-element for non-power-of-2 codegen git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46486 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 54cfad69309..d18d4d959b4 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/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(Idx)) { + unsigned NumLoElts = 1 << Log2_32(NumElems-1); ConstantSDNode *CIdx = cast(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()); }