@@ -3069,7 +3069,7 @@ bool VPReplicateRecipe::shouldPack() const {
30693069}
30703070
30713071// / Returns true if \p Ptr is a pointer computation for which the legacy cost
3072- // / model computes a SCEV expression when comping the address cost.
3072+ // / model computes a SCEV expression when computing the address cost.
30733073static bool shouldUseAddressAccessSCEV (VPValue *Ptr) {
30743074 auto *PtrR = Ptr->getDefiningRecipe ();
30753075 if (!PtrR || !((isa<VPReplicateRecipe>(PtrR) &&
@@ -3078,20 +3078,20 @@ static bool shouldUseAddressAccessSCEV(VPValue *Ptr) {
30783078 isa<VPWidenGEPRecipe>(PtrR)))
30793079 return false ;
30803080
3081- // We are looking for a gep with all loop invariant indices except for one
3081+ // We are looking for a GEP with all loop invariant indices except for one
30823082 // which should be an induction variable.
30833083 unsigned NumOperands = PtrR->getNumOperands ();
30843084 for (unsigned Idx = 1 ; Idx < NumOperands; ++Idx) {
30853085 VPValue *Opd = PtrR->getOperand (Idx);
3086- if (!( Opd->isDefinedOutsideLoopRegions () ) &&
3086+ if (!Opd->isDefinedOutsideLoopRegions () &&
30873087 !isa<VPScalarIVStepsRecipe, VPWidenIntOrFpInductionRecipe>(Opd))
30883088 return false ;
30893089 }
30903090
30913091 return true ;
30923092}
30933093
3094- // / Returns true of \p V is used as part of the address of another load or
3094+ // / Returns true if \p V is used as part of the address of another load or
30953095// / store.
30963096static bool isUsedByLoadStoreAddress (const VPUser *V) {
30973097 SmallPtrSet<const VPUser *, 4 > Seen;
@@ -3103,7 +3103,7 @@ static bool isUsedByLoadStoreAddress(const VPUser *V) {
31033103 continue ;
31043104
31053105 for (VPUser *U : Cur->users ()) {
3106- if (auto *InterleaveR = dyn_cast<VPInterleaveRecipe >(U))
3106+ if (auto *InterleaveR = dyn_cast<VPInterleaveBase >(U))
31073107 if (InterleaveR->getAddr () == Cur)
31083108 return true ;
31093109 if (auto *RepR = dyn_cast<VPReplicateRecipe>(U)) {
@@ -3237,7 +3237,8 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
32373237
32383238 // TODO: See getMemInstScalarizationCost for how to handle replicating and
32393239 // predicated cases.
3240- if (getParent ()->getParent () && getParent ()->getParent ()->isReplicator ())
3240+ const VPRegionBlock *ParentRegion = getParent ()->getParent ();
3241+ if (ParentRegion && ParentRegion->isReplicator ())
32413242 break ;
32423243
32433244 bool IsLoad = UI->getOpcode () == Instruction::Load;
@@ -3263,18 +3264,20 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
32633264 return ScalarCost;
32643265
32653266 SmallVector<const VPValue *> OpsToScalarize;
3266- Type *ResultTy = Type::getVoidTy (getParent ()-> getPlan () ->getContext ());
3267+ Type *ResultTy = Type::getVoidTy (PtrTy ->getContext ());
32673268 // Set ResultTy and OpsToScalarize, if scalarization is needed. Currently we
32683269 // don't assign scalarization overhead in general, if the target prefers
32693270 // vectorized addressing or the loaded value is used as part of an address
32703271 // of another load or store.
3271- if (Ctx.TTI .prefersVectorizedAddressing () ||
3272- !isUsedByLoadStoreAddress (this )) {
3273- if (!(IsLoad && !Ctx.TTI .prefersVectorizedAddressing ()) &&
3274- !(!IsLoad && Ctx.TTI .supportsEfficientVectorElementLoadStore ()))
3272+ bool PreferVectorizedAddressing = Ctx.TTI .prefersVectorizedAddressing ();
3273+ if (PreferVectorizedAddressing || !isUsedByLoadStoreAddress (this )) {
3274+ bool EfficientVectorLoadStore =
3275+ Ctx.TTI .supportsEfficientVectorElementLoadStore ();
3276+ if (!(IsLoad && !PreferVectorizedAddressing) &&
3277+ !(!IsLoad && EfficientVectorLoadStore))
32753278 append_range (OpsToScalarize, operands ());
32763279
3277- if (!Ctx. TTI . supportsEfficientVectorElementLoadStore () )
3280+ if (!EfficientVectorLoadStore )
32783281 ResultTy = Ctx.Types .inferScalarType (this );
32793282 }
32803283
0 commit comments