diff options
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index f05f4445a8..058e60f5fc 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1838,6 +1838,28 @@ bool SelectionDAG::isVerifiedDebugInfoDesc(SDOperand Op) const { } +/// getShuffleScalarElt - Returns the scalar element that will make up the ith +/// element of the result of the vector shuffle. +SDOperand SelectionDAG::getShuffleScalarElt(const SDNode *N, unsigned Idx) { + MVT::ValueType VT = N->getValueType(0); + SDOperand PermMask = N->getOperand(2); + unsigned NumElems = PermMask.getNumOperands(); + SDOperand V = (Idx < NumElems) ? N->getOperand(0) : N->getOperand(1); + Idx %= NumElems; + if (V.getOpcode() == ISD::SCALAR_TO_VECTOR) { + return (Idx == 0) + ? V.getOperand(0) : getNode(ISD::UNDEF, MVT::getVectorElementType(VT)); + } + if (V.getOpcode() == ISD::VECTOR_SHUFFLE) { + SDOperand Elt = PermMask.getOperand(Idx); + if (Elt.getOpcode() == ISD::UNDEF) + return getNode(ISD::UNDEF, MVT::getVectorElementType(VT)); + return getShuffleScalarElt(V.Val,cast<ConstantSDNode>(Elt)->getValue()); + } + return SDOperand(); +} + + /// getNode - Gets or creates the specified node. /// SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT) { |