@@ -3642,7 +3642,7 @@ InstructionCost AArch64TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
36423642
36433643InstructionCost
36443644AArch64TTIImpl::getExtractWithExtendCost (unsigned Opcode, Type *Dst,
3645- VectorType *VecTy, unsigned Index,
3645+ VectorType *VecTy, int Index,
36463646 TTI::TargetCostKind CostKind) const {
36473647
36483648 // Make sure we were given a valid extend opcode.
@@ -3711,12 +3711,12 @@ InstructionCost AArch64TTIImpl::getCFInstrCost(unsigned Opcode,
37113711}
37123712
37133713InstructionCost AArch64TTIImpl::getVectorInstrCostHelper (
3714- unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
3714+ unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, int Index,
37153715 bool HasRealUse, const Instruction *I, Value *Scalar,
37163716 ArrayRef<std::tuple<Value *, User *, int >> ScalarUserAndIdx) const {
37173717 assert (Val->isVectorTy () && " This must be a vector type" );
37183718
3719- if (Index != - 1U ) {
3719+ if (TargetTransformInfo::isKnownVectorIndex ( Index) ) {
37203720 // Legalize the type.
37213721 std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost (Val);
37223722
@@ -3884,16 +3884,15 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
38843884
38853885InstructionCost AArch64TTIImpl::getVectorInstrCost (unsigned Opcode, Type *Val,
38863886 TTI::TargetCostKind CostKind,
3887- unsigned Index,
3888- const Value *Op0,
3887+ int Index, const Value *Op0,
38893888 const Value *Op1) const {
38903889 bool HasRealUse =
38913890 Opcode == Instruction::InsertElement && Op0 && !isa<UndefValue>(Op0);
38923891 return getVectorInstrCostHelper (Opcode, Val, CostKind, Index, HasRealUse);
38933892}
38943893
38953894InstructionCost AArch64TTIImpl::getVectorInstrCost (
3896- unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
3895+ unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, int Index,
38973896 Value *Scalar,
38983897 ArrayRef<std::tuple<Value *, User *, int >> ScalarUserAndIdx) const {
38993898 return getVectorInstrCostHelper (Opcode, Val, CostKind, Index, false , nullptr ,
@@ -3903,7 +3902,7 @@ InstructionCost AArch64TTIImpl::getVectorInstrCost(
39033902InstructionCost AArch64TTIImpl::getVectorInstrCost (const Instruction &I,
39043903 Type *Val,
39053904 TTI::TargetCostKind CostKind,
3906- unsigned Index) const {
3905+ int Index) const {
39073906 return getVectorInstrCostHelper (I.getOpcode (), Val, CostKind, Index,
39083907 true /* HasRealUse */ , &I);
39093908}
@@ -4052,10 +4051,13 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
40524051 // loading the vector from constant pool or in some cases, may also result
40534052 // in scalarization. For now, we are approximating this with the
40544053 // scalarization cost.
4055- auto ExtractCost = 2 * getVectorInstrCost (Instruction::ExtractElement, Ty,
4056- CostKind, -1 , nullptr , nullptr );
4057- auto InsertCost = getVectorInstrCost (Instruction::InsertElement, Ty,
4058- CostKind, -1 , nullptr , nullptr );
4054+ auto ExtractCost =
4055+ 2 * getVectorInstrCost (Instruction::ExtractElement, Ty, CostKind,
4056+ TargetTransformInfo::UnknownIndex, nullptr ,
4057+ nullptr );
4058+ auto InsertCost = getVectorInstrCost (
4059+ Instruction::InsertElement, Ty, CostKind,
4060+ TargetTransformInfo::UnknownIndex, nullptr , nullptr );
40594061 unsigned NElts = cast<FixedVectorType>(Ty)->getNumElements ();
40604062 return ExtractCost + InsertCost +
40614063 NElts * getArithmeticInstrCost (Opcode, Ty->getScalarType (),
@@ -4153,9 +4155,11 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
41534155 // On AArch64, without SVE, vector divisions are expanded
41544156 // into scalar divisions of each pair of elements.
41554157 Cost += getVectorInstrCost (Instruction::ExtractElement, Ty, CostKind,
4156- -1 , nullptr , nullptr );
4157- Cost += getVectorInstrCost (Instruction::InsertElement, Ty, CostKind, -1 ,
4158- nullptr , nullptr );
4158+ TargetTransformInfo::UnknownIndex, nullptr ,
4159+ nullptr );
4160+ Cost += getVectorInstrCost (Instruction::InsertElement, Ty, CostKind,
4161+ TargetTransformInfo::UnknownIndex, nullptr ,
4162+ nullptr );
41594163 }
41604164
41614165 // TODO: if one of the arguments is scalar, then it's not necessary to
@@ -4186,11 +4190,13 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
41864190 return LT.first ;
41874191 return cast<VectorType>(Ty)->getElementCount ().getKnownMinValue () *
41884192 (getArithmeticInstrCost (Opcode, Ty->getScalarType (), CostKind) +
4189- getVectorInstrCost (Instruction::ExtractElement, Ty, CostKind, -1 ,
4190- nullptr , nullptr ) *
4193+ getVectorInstrCost (Instruction::ExtractElement, Ty, CostKind,
4194+ TargetTransformInfo::UnknownIndex, nullptr ,
4195+ nullptr ) *
41914196 2 +
4192- getVectorInstrCost (Instruction::InsertElement, Ty, CostKind, -1 ,
4193- nullptr , nullptr ));
4197+ getVectorInstrCost (Instruction::InsertElement, Ty, CostKind,
4198+ TargetTransformInfo::UnknownIndex, nullptr ,
4199+ nullptr ));
41944200 case ISD::ADD:
41954201 case ISD::XOR:
41964202 case ISD::OR:
0 commit comments