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