@@ -1569,8 +1569,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1569
1569
Type *RetTy = ICA.getReturnType ();
1570
1570
1571
1571
ElementCount RetVF =
1572
- isWideTy (RetTy) ? getWideTypeVF (RetTy) : ElementCount::getFixed ( 1 );
1573
-
1572
+ (RetTy-> isVectorTy ( ) ? cast<VectorType> (RetTy)-> getElementCount ()
1573
+ : ElementCount::getFixed ( 1 ));
1574
1574
const IntrinsicInst *I = ICA.getInst ();
1575
1575
const SmallVectorImpl<const Value *> &Args = ICA.getArgs ();
1576
1576
FastMathFlags FMF = ICA.getFlags ();
@@ -1891,13 +1891,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1891
1891
InstructionCost ScalarizationCost = InstructionCost::getInvalid ();
1892
1892
if (RetVF.isVector () && !RetVF.isScalable ()) {
1893
1893
ScalarizationCost = 0 ;
1894
- if (!RetTy->isVoidTy ()) {
1895
- for (Type *VectorTy : getContainedTypes (RetTy)) {
1896
- ScalarizationCost += getScalarizationOverhead (
1897
- cast<VectorType>(VectorTy),
1898
- /* Insert*/ true , /* Extract*/ false , CostKind);
1899
- }
1900
- }
1894
+ if (!RetTy->isVoidTy ())
1895
+ ScalarizationCost += getScalarizationOverhead (
1896
+ cast<VectorType>(RetTy),
1897
+ /* Insert*/ true , /* Extract*/ false , CostKind);
1901
1898
ScalarizationCost +=
1902
1899
getOperandsScalarizationOverhead (Args, ICA.getArgTypes (), CostKind);
1903
1900
}
@@ -2488,32 +2485,27 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2488
2485
// Else, assume that we need to scalarize this intrinsic. For math builtins
2489
2486
// this will emit a costly libcall, adding call overhead and spills. Make it
2490
2487
// very expensive.
2491
- if (isWideTy (RetTy)) {
2492
- const SmallVector<Type *, 2 > RetVTys = getContainedTypes (RetTy);
2493
-
2488
+ if (auto *RetVTy = dyn_cast<VectorType>(RetTy)) {
2494
2489
// Scalable vectors cannot be scalarized, so return Invalid.
2495
- if (any_of (concat<Type *const >(RetVTys, Tys),
2496
- [](Type *Ty) { return isa<ScalableVectorType>(Ty); }))
2490
+ if (isa<ScalableVectorType>(RetTy) || any_of (Tys, [](const Type *Ty) {
2491
+ return isa<ScalableVectorType>(Ty);
2492
+ }))
2497
2493
return InstructionCost::getInvalid ();
2498
2494
2499
- InstructionCost ScalarizationCost = ScalarizationCostPassed;
2500
- if (!SkipScalarizationCost) {
2501
- ScalarizationCost = 0 ;
2502
- for (Type *RetVTy : RetVTys) {
2503
- ScalarizationCost += getScalarizationOverhead (
2504
- cast<VectorType>(RetVTy), /* Insert*/ true ,
2505
- /* Extract*/ false , CostKind);
2506
- }
2507
- }
2495
+ InstructionCost ScalarizationCost =
2496
+ SkipScalarizationCost
2497
+ ? ScalarizationCostPassed
2498
+ : getScalarizationOverhead (RetVTy, /* Insert*/ true ,
2499
+ /* Extract*/ false , CostKind);
2508
2500
2509
- unsigned ScalarCalls = getWideTypeVF (RetTy). getFixedValue ();
2501
+ unsigned ScalarCalls = cast<FixedVectorType>(RetVTy)-> getNumElements ();
2510
2502
SmallVector<Type *, 4 > ScalarTys;
2511
2503
for (Type *Ty : Tys) {
2512
2504
if (Ty->isVectorTy ())
2513
2505
Ty = Ty->getScalarType ();
2514
2506
ScalarTys.push_back (Ty);
2515
2507
}
2516
- IntrinsicCostAttributes Attrs (IID, ToNarrowTy ( RetTy), ScalarTys, FMF);
2508
+ IntrinsicCostAttributes Attrs (IID, RetTy-> getScalarType ( ), ScalarTys, FMF);
2517
2509
InstructionCost ScalarCost =
2518
2510
thisT ()->getIntrinsicInstrCost (Attrs, CostKind);
2519
2511
for (Type *Ty : Tys) {
0 commit comments