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