summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2007-07-10 18:20:44 +0000
committerDan Gohman <gohman@apple.com>2007-07-10 18:20:44 +0000
commit60d6f96da37b8cc2f991645ad3a5f902f7f9d46f (patch)
treeace55d48b474d0467f12666dbfbcb214c852bdab /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent94a21dd1e01bc943f6cd5122aeaadab76936d990 (diff)
downloadbcm5719-llvm-60d6f96da37b8cc2f991645ad3a5f902f7f9d46f.tar.gz
bcm5719-llvm-60d6f96da37b8cc2f991645ad3a5f902f7f9d46f.zip
Change the peep for EXTRACT_VECTOR_ELT of BUILD_PAIR to look for
the new CONCAT_VECTORS node type instead, as that's what legalize uses now. And add a peep for EXTRACT_VECTOR_ELT of INSERT_VECTOR_ELT. llvm-svn: 38503
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 9687a52cdab..dc23151bddd 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1968,19 +1968,31 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
case ISD::EXTRACT_VECTOR_ELT:
assert(N2C && "Bad EXTRACT_VECTOR_ELT!");
- // EXTRACT_VECTOR_ELT of BUILD_PAIR is often formed while lowering is
+ // EXTRACT_VECTOR_ELT of CONCAT_VECTORS is often formed while lowering is
// expanding copies of large vectors from registers.
- if (N1.getOpcode() == ISD::BUILD_PAIR) {
- unsigned NewNumElts = MVT::getVectorNumElements(N1.getValueType()) / 2;
- bool Low = N2C->getValue() < NewNumElts;
- return getNode(ISD::EXTRACT_VECTOR_ELT, VT, N1.getOperand(!Low),
- Low ? N2 : getConstant(N2C->getValue() - NewNumElts,
- N2.getValueType()));
+ if (N1.getOpcode() == ISD::CONCAT_VECTORS &&
+ N1.getNumOperands() > 0) {
+ unsigned Factor =
+ MVT::getVectorNumElements(N1.getOperand(0).getValueType());
+ return getNode(ISD::EXTRACT_VECTOR_ELT, VT,
+ N1.getOperand(N2C->getValue() / Factor),
+ getConstant(N2C->getValue() % Factor, N2.getValueType()));
}
+
// EXTRACT_VECTOR_ELT of BUILD_VECTOR is often formed while lowering is
// expanding large vector constants.
if (N1.getOpcode() == ISD::BUILD_VECTOR)
return N1.getOperand(N2C->getValue());
+
+ // EXTRACT_VECTOR_ELT of INSERT_VECTOR_ELT is often formed when vector
+ // operations are lowered to scalars.
+ if (N1.getOpcode() == ISD::INSERT_VECTOR_ELT)
+ if (ConstantSDNode *IEC = dyn_cast<ConstantSDNode>(N1.getOperand(2))) {
+ if (IEC == N2C)
+ return N1.getOperand(1);
+ else
+ return getNode(ISD::EXTRACT_VECTOR_ELT, VT, N1.getOperand(0), N2);
+ }
break;
case ISD::EXTRACT_ELEMENT:
assert(N2C && (unsigned)N2C->getValue() < 2 && "Bad EXTRACT_ELEMENT!");
OpenPOWER on IntegriCloud