Fix a performance regression. Use {p}shuf* when there are only two distinct elements in a build_vector.

llvm-svn: 27945
This commit is contained in:
Evan Cheng 2006-04-22 06:21:46 +00:00
parent 40ff2928ed
commit 16ef94f4e8
1 changed files with 17 additions and 13 deletions

View File

@ -3274,22 +3274,26 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
return DAG.getNode(ISD::VECTOR_SHUFFLE, VT, V[0], V[1], ShufMask); return DAG.getNode(ISD::VECTOR_SHUFFLE, VT, V[0], V[1], ShufMask);
} }
// Expand into a number of unpckl*. if (Values.size() > 2) {
// e.g. for v4f32 // Expand into a number of unpckl*.
// Step 1: unpcklps 0, 2 ==> X: <?, ?, 2, 0> // e.g. for v4f32
// : unpcklps 1, 3 ==> Y: <?, ?, 3, 1> // Step 1: unpcklps 0, 2 ==> X: <?, ?, 2, 0>
// Step 2: unpcklps X, Y ==> <3, 2, 1, 0> // : unpcklps 1, 3 ==> Y: <?, ?, 3, 1>
SDOperand UnpckMask = getUnpacklMask(NumElems, DAG); // Step 2: unpcklps X, Y ==> <3, 2, 1, 0>
for (unsigned i = 0; i < NumElems; ++i) SDOperand UnpckMask = getUnpacklMask(NumElems, DAG);
V[i] = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, Op.getOperand(i));
NumElems >>= 1;
while (NumElems != 0) {
for (unsigned i = 0; i < NumElems; ++i) for (unsigned i = 0; i < NumElems; ++i)
V[i] = DAG.getNode(ISD::VECTOR_SHUFFLE, VT, V[i], V[i + NumElems], V[i] = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, Op.getOperand(i));
UnpckMask);
NumElems >>= 1; NumElems >>= 1;
while (NumElems != 0) {
for (unsigned i = 0; i < NumElems; ++i)
V[i] = DAG.getNode(ISD::VECTOR_SHUFFLE, VT, V[i], V[i + NumElems],
UnpckMask);
NumElems >>= 1;
}
return V[0];
} }
return V[0];
return SDOperand();
} }
case ISD::EXTRACT_VECTOR_ELT: { case ISD::EXTRACT_VECTOR_ELT: {
if (!isa<ConstantSDNode>(Op.getOperand(1))) if (!isa<ConstantSDNode>(Op.getOperand(1)))