Skip to content

Commit f8b12f7

Browse files
committed
[AArch64] Don't model legal subvector insert/extract as scalarization
1 parent 4047162 commit f8b12f7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,32 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
568568
}
569569
return Cost;
570570
}
571+
case Intrinsic::vector_extract: {
572+
// If both the vector argument and the return type are legal types, then
573+
// this should be a no-op or simple operation; return a relatively low cost.
574+
LLVMContext &C = RetTy->getContext();
575+
EVT MRTy = getTLI()->getValueType(DL, RetTy);
576+
EVT MPTy = getTLI()->getValueType(DL, ICA.getArgTypes()[0]);
577+
TargetLoweringBase::LegalizeKind RLK = getTLI()->getTypeConversion(C, MRTy);
578+
TargetLoweringBase::LegalizeKind PLK = getTLI()->getTypeConversion(C, MPTy);
579+
if (RLK.first == TargetLoweringBase::TypeLegal &&
580+
PLK.first == TargetLoweringBase::TypeLegal)
581+
return InstructionCost(1);
582+
break;
583+
}
584+
case Intrinsic::vector_insert: {
585+
// If both the vector and subvector arguments are legal types, then this
586+
// should be a no-op or simple operation; return a relatively low cost.
587+
LLVMContext &C = RetTy->getContext();
588+
EVT MTy0 = getTLI()->getValueType(DL, ICA.getArgTypes()[0]);
589+
EVT MTy1 = getTLI()->getValueType(DL, ICA.getArgTypes()[1]);
590+
TargetLoweringBase::LegalizeKind LK0 = getTLI()->getTypeConversion(C, MTy0);
591+
TargetLoweringBase::LegalizeKind LK1 = getTLI()->getTypeConversion(C, MTy1);
592+
if (LK0.first == TargetLoweringBase::TypeLegal &&
593+
LK1.first == TargetLoweringBase::TypeLegal)
594+
return InstructionCost(1);
595+
break;
596+
}
571597
case Intrinsic::bitreverse: {
572598
static const CostTblEntry BitreverseTbl[] = {
573599
{Intrinsic::bitreverse, MVT::i32, 1},

0 commit comments

Comments
 (0)