mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-12 13:48:45 +00:00
[DAGCombiner] Do a better job of ensuring we don't split elements when combining an extract_subvector of a bitcasted build_vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312253 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2c1824ad05
commit
c3f43cf233
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user