@@ -2105,6 +2105,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2105
2105
}
2106
2106
case Intrinsic::get_active_lane_mask:
2107
2107
case Intrinsic::experimental_vector_match:
2108
+ case Intrinsic::experimental_vector_histogram_add:
2109
+ case Intrinsic::experimental_vector_histogram_uadd_sat:
2110
+ case Intrinsic::experimental_vector_histogram_umax:
2111
+ case Intrinsic::experimental_vector_histogram_umin:
2108
2112
return thisT ()->getTypeBasedIntrinsicInstrCost (ICA, CostKind);
2109
2113
case Intrinsic::modf:
2110
2114
case Intrinsic::sincos:
@@ -2457,6 +2461,51 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2457
2461
return thisT ()->getShuffleCost (TTI::SK_Reverse, cast<VectorType>(RetTy),
2458
2462
cast<VectorType>(ICA.getArgTypes ()[0 ]), {},
2459
2463
CostKind, 0 , cast<VectorType>(RetTy));
2464
+ case Intrinsic::experimental_vector_histogram_add:
2465
+ case Intrinsic::experimental_vector_histogram_uadd_sat:
2466
+ case Intrinsic::experimental_vector_histogram_umax:
2467
+ case Intrinsic::experimental_vector_histogram_umin: {
2468
+ FixedVectorType *PtrsTy = dyn_cast<FixedVectorType>(ICA.getArgTypes ()[0 ]);
2469
+ Type *EltTy = ICA.getArgTypes ()[1 ];
2470
+
2471
+ // Targets with scalable vectors must handle this on their own.
2472
+ if (!PtrsTy)
2473
+ return InstructionCost::getInvalid ();
2474
+
2475
+ Align Alignment = thisT ()->DL .getABITypeAlign (EltTy);
2476
+ InstructionCost Cost = 0 ;
2477
+ Cost += thisT ()->getVectorInstrCost (Instruction::ExtractElement, PtrsTy,
2478
+ CostKind, 1 , nullptr , nullptr );
2479
+ Cost += thisT ()->getMemoryOpCost (Instruction::Load, EltTy, Alignment, 0 ,
2480
+ CostKind);
2481
+ switch (IID) {
2482
+ default :
2483
+ llvm_unreachable (" Unhandled histogram update operation." );
2484
+ case Intrinsic::experimental_vector_histogram_add:
2485
+ Cost +=
2486
+ thisT ()->getArithmeticInstrCost (Instruction::Add, EltTy, CostKind);
2487
+ break ;
2488
+ case Intrinsic::experimental_vector_histogram_uadd_sat: {
2489
+ IntrinsicCostAttributes UAddSat (Intrinsic::uadd_sat, EltTy, {EltTy});
2490
+ Cost += thisT ()->getIntrinsicInstrCost (UAddSat, CostKind);
2491
+ break ;
2492
+ }
2493
+ case Intrinsic::experimental_vector_histogram_umax: {
2494
+ IntrinsicCostAttributes UMax (Intrinsic::umax, EltTy, {EltTy});
2495
+ Cost += thisT ()->getIntrinsicInstrCost (UMax, CostKind);
2496
+ break ;
2497
+ }
2498
+ case Intrinsic::experimental_vector_histogram_umin: {
2499
+ IntrinsicCostAttributes UMin (Intrinsic::umin, EltTy, {EltTy});
2500
+ Cost += thisT ()->getIntrinsicInstrCost (UMin, CostKind);
2501
+ break ;
2502
+ }
2503
+ }
2504
+ Cost += thisT ()->getMemoryOpCost (Instruction::Store, EltTy, Alignment, 0 ,
2505
+ CostKind);
2506
+ Cost *= PtrsTy->getNumElements ();
2507
+ return Cost;
2508
+ }
2460
2509
case Intrinsic::get_active_lane_mask: {
2461
2510
Type *ArgTy = ICA.getArgTypes ()[0 ];
2462
2511
EVT ResVT = getTLI ()->getValueType (DL, RetTy, true );
0 commit comments