Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6173,8 +6173,7 @@ LegalizerHelper::equalizeVectorShuffleLengths(MachineInstr &MI) {
// Extend mask to match new destination vector size with
// undef values.
SmallVector<int, 16> NewMask(Mask);
for (unsigned I = MaskNumElts; I < SrcNumElts; ++I)
NewMask.push_back(-1);
NewMask.resize(SrcNumElts, -1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the constructor variant as you did in moreElementsVectorShuffle()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're already using the constructor to copy the first part of the Mask. We could do

SmallVector<int, 16> NewMask(SrcNumElts, -1);
std::copy(NewMask.begin(), Mask.begin(), Mask.end())

Then we'd have the correct size at the start.


moreElementsVectorDst(MI, SrcTy, 0);
MIRBuilder.setInstrAndDebugLoc(MI);
Expand Down Expand Up @@ -6254,16 +6253,14 @@ LegalizerHelper::moreElementsVectorShuffle(MachineInstr &MI,
moreElementsVectorSrc(MI, MoreTy, 2);

// Adjust mask based on new input vector length.
SmallVector<int, 16> NewMask;
SmallVector<int, 16> NewMask(WidenNumElts, -1);
for (unsigned I = 0; I != NumElts; ++I) {
int Idx = Mask[I];
if (Idx < static_cast<int>(NumElts))
NewMask.push_back(Idx);
NewMask[I] = Idx;
else
NewMask.push_back(Idx - NumElts + WidenNumElts);
NewMask[I] = Idx - NumElts + WidenNumElts;
}
for (unsigned I = NumElts; I != WidenNumElts; ++I)
NewMask.push_back(-1);
moreElementsVectorDst(MI, MoreTy, 0);
MIRBuilder.setInstrAndDebugLoc(MI);
MIRBuilder.buildShuffleVector(MI.getOperand(0).getReg(),
Expand Down
17 changes: 6 additions & 11 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6421,16 +6421,14 @@ SDValue DAGTypeLegalizer::WidenVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N) {
SDValue InOp2 = GetWidenedVector(N->getOperand(1));

// Adjust mask based on new input vector length.
SmallVector<int, 16> NewMask;
SmallVector<int, 16> NewMask(WidenNumElts, -1);
for (unsigned i = 0; i != NumElts; ++i) {
int Idx = N->getMaskElt(i);
if (Idx < (int)NumElts)
NewMask.push_back(Idx);
NewMask[i] = Idx;
else
NewMask.push_back(Idx - NumElts + WidenNumElts);
NewMask[i] = Idx - NumElts + WidenNumElts;
}
for (unsigned i = NumElts; i != WidenNumElts; ++i)
NewMask.push_back(-1);
return DAG.getVectorShuffle(WidenVT, dl, InOp1, InOp2, NewMask);
}

Expand Down Expand Up @@ -6478,12 +6476,9 @@ SDValue DAGTypeLegalizer::WidenVecRes_VECTOR_REVERSE(SDNode *N) {

// Use VECTOR_SHUFFLE to combine new vector from 'ReverseVal' for
// fixed-vectors.
SmallVector<int, 16> Mask;
for (unsigned i = 0; i != VTNumElts; ++i) {
Mask.push_back(IdxVal + i);
}
for (unsigned i = VTNumElts; i != WidenNumElts; ++i)
Mask.push_back(-1);
SmallVector<int, 16> Mask(VTNumElts, -1);
for (unsigned i = 0; i != VTNumElts; ++i)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use std::iota?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

I messed up the size here. I should have used WidenNumElts in the constructor. Need to see why nothing failed.

Mask[i] = IdxVal + i;

return DAG.getVectorShuffle(WidenVT, dl, ReverseVal, DAG.getUNDEF(WidenVT),
Mask);
Expand Down
Loading