@@ -3070,19 +3070,17 @@ bool VPReplicateRecipe::shouldPack() const {
30703070
30713071// / Returns true if \p Ptr is a pointer computation for which the legacy cost
30723072// / model computes a SCEV expression when computing the address cost.
3073- static bool shouldUseAddressAccessSCEV (VPValue *Ptr) {
3073+ static bool shouldUseAddressAccessSCEV (const VPValue *Ptr) {
30743074 auto *PtrR = Ptr->getDefiningRecipe ();
30753075 if (!PtrR || !((isa<VPReplicateRecipe>(PtrR) &&
30763076 cast<VPReplicateRecipe>(PtrR)->getOpcode () ==
30773077 Instruction::GetElementPtr) ||
30783078 isa<VPWidenGEPRecipe>(PtrR)))
30793079 return false ;
30803080
3081- // We are looking for a GEP with all loop invariant indices except for one
3082- // which should be an induction variable.
3083- unsigned NumOperands = PtrR->getNumOperands ();
3084- for (unsigned Idx = 1 ; Idx < NumOperands; ++Idx) {
3085- VPValue *Opd = PtrR->getOperand (Idx);
3081+ // We are looking for a GEP where all indices are either loop invariant or
3082+ // inductions.
3083+ for (VPValue *Opd : drop_begin (PtrR->operands ())) {
30863084 if (!Opd->isDefinedOutsideLoopRegions () &&
30873085 !isa<VPScalarIVStepsRecipe, VPWidenIntOrFpInductionRecipe>(Opd))
30883086 return false ;
@@ -3242,13 +3240,14 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
32423240 break ;
32433241
32443242 bool IsLoad = UI->getOpcode () == Instruction::Load;
3243+ const VPValue *PtrOp = getOperand (!IsLoad);
32453244 // TODO: Handle cases where we need to pass a SCEV to
32463245 // getAddressComputationCost.
3247- if (shouldUseAddressAccessSCEV (getOperand (!IsLoad) ))
3246+ if (shouldUseAddressAccessSCEV (PtrOp ))
32483247 break ;
32493248
32503249 Type *ValTy = Ctx.Types .inferScalarType (IsLoad ? this : getOperand (0 ));
3251- Type *ScalarPtrTy = Ctx.Types .inferScalarType (getOperand (IsLoad ? 0 : 1 ) );
3250+ Type *ScalarPtrTy = Ctx.Types .inferScalarType (PtrOp );
32523251 const Align Alignment = getLoadStoreAlignment (UI);
32533252 unsigned AS = getLoadStoreAddressSpace (UI);
32543253 TTI::OperandValueInfo OpInfo = TTI::getOperandInfo (UI->getOperand (0 ));
0 commit comments