diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-05-13 08:35:03 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-05-13 08:35:03 +0000 |
commit | 1120279ae6f2a502093a0c20c1b8d5d4dfd44e4c (patch) | |
tree | b9c9615435314d840be21c498984860c0600af65 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 525aa89356515867b52d584991b9e2a0db294c97 (diff) | |
download | bcm5719-llvm-1120279ae6f2a502093a0c20c1b8d5d4dfd44e4c.tar.gz bcm5719-llvm-1120279ae6f2a502093a0c20c1b8d5d4dfd44e4c.zip |
Instead of a vector load, shuffle and then extract an element. Load the element from address with an offset.
pshufd $1, (%rdi), %xmm0
movd %xmm0, %eax
=>
movl 4(%rdi), %eax
llvm-svn: 51026
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index f05f4445a8f..058e60f5fc8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/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) { |