Skip to content

[CostModel] TargetTransformInfoImplCRTPBase.getInstructionCost - move shuffle analysis into improveShuffleKindFromMask / target getShuffleCost #145335

Open
@RKSimon

Description

@RKSimon

As discussed on #144690 and #141634 - we're making too many assumptions about how length changing shuffles are legalized by the target. These need to be driven by the actual target implementations.

Additionally - like getInstructionCost - improveShuffleKindFromMask needs to be able to recognize a SK_PermuteSingleSrc class shuffle that has been miss-tagged as a SK_PermuteTwoSrc class.

CC @davemgreen @preames

case Instruction::ShuffleVector: {
auto *Shuffle = dyn_cast<ShuffleVectorInst>(U);
if (!Shuffle)
return TTI::TCC_Basic; // FIXME
auto *VecTy = cast<VectorType>(U->getType());
auto *VecSrcTy = cast<VectorType>(Operands[0]->getType());
ArrayRef<int> Mask = Shuffle->getShuffleMask();
int NumSubElts, SubIndex;
// TODO: move more of this inside improveShuffleKindFromMask.
if (Shuffle->changesLength()) {
// Treat a 'subvector widening' as a free shuffle.
if (Shuffle->increasesLength() && Shuffle->isIdentityWithPadding())
return 0;
if (Shuffle->isExtractSubvectorMask(SubIndex))
return TargetTTI->getShuffleCost(TTI::SK_ExtractSubvector, VecTy,
VecSrcTy, Mask, CostKind, SubIndex,
VecTy, Operands, Shuffle);

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvm:analysisIncludes value tracking, cost tables and constant folding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions