diff options
author | Craig Topper <craig.topper@intel.com> | 2017-08-31 17:02:22 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2017-08-31 17:02:22 +0000 |
commit | 7081f029f3d05232a6f5691aba93c4c2e8486b35 (patch) | |
tree | 91276c0f8202950caf9f6baa1f8fe59dfc463f88 /llvm/lib/CodeGen/SelectionDAG | |
parent | 8ac8df03c10c98b1f782b4e0df201361ee4ee067 (diff) | |
download | bcm5719-llvm-7081f029f3d05232a6f5691aba93c4c2e8486b35.tar.gz bcm5719-llvm-7081f029f3d05232a6f5691aba93c4c2e8486b35.zip |
[DAGCombiner] Do a better job of ensuring we don't split elements when combining an extract_subvector of a bitcasted build_vector.
llvm-svn: 312253
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index db87f8a6275..6dbfced44d1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -15173,14 +15173,17 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode* N) { if (V->getOpcode() == ISD::BUILD_VECTOR) { if (auto *Idx = dyn_cast<ConstantSDNode>(N->getOperand(1))) { EVT InVT = V->getValueType(0); - unsigned NumElems = NVT.getSizeInBits() / InVT.getScalarSizeInBits(); - if (NumElems > 0) { + unsigned ExtractSize = NVT.getSizeInBits(); + unsigned EltSize = InVT.getScalarSizeInBits(); + // Only do this if we won't split any elements. + if (ExtractSize % EltSize == 0) { + unsigned NumElems = ExtractSize / EltSize; EVT ExtractVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(), NumElems); if (!LegalOperations || TLI.isOperationLegal(ISD::BUILD_VECTOR, ExtractVT)) { - unsigned IdxVal = Idx->getZExtValue() * NVT.getScalarSizeInBits() / - InVT.getScalarSizeInBits(); + unsigned IdxVal = (Idx->getZExtValue() * NVT.getScalarSizeInBits()) / + EltSize; // Extract the pieces from the original build_vector. SDValue BuildVec = DAG.getBuildVector(ExtractVT, SDLoc(N), |