@@ -1027,88 +1027,6 @@ bool PPCTTIImpl::getTgtMemIntrinsic(IntrinsicInst *Inst,
10271027 return false ;
10281028}
10291029
1030- bool PPCTTIImpl::hasActiveVectorLength (unsigned Opcode, Type *DataType,
1031- Align Alignment) const {
1032- // Only load and stores instructions can have variable vector length on Power.
1033- if (Opcode != Instruction::Load && Opcode != Instruction::Store)
1034- return false ;
1035- // Loads/stores with length instructions use bits 0-7 of the GPR operand and
1036- // therefore cannot be used in 32-bit mode.
1037- if ((!ST->hasP9Vector () && !ST->hasP10Vector ()) || !ST->isPPC64 ())
1038- return false ;
1039- if (isa<FixedVectorType>(DataType)) {
1040- unsigned VecWidth = DataType->getPrimitiveSizeInBits ();
1041- return VecWidth == 128 ;
1042- }
1043- Type *ScalarTy = DataType->getScalarType ();
1044-
1045- if (ScalarTy->isPointerTy ())
1046- return true ;
1047-
1048- if (ScalarTy->isFloatTy () || ScalarTy->isDoubleTy ())
1049- return true ;
1050-
1051- if (!ScalarTy->isIntegerTy ())
1052- return false ;
1053-
1054- unsigned IntWidth = ScalarTy->getIntegerBitWidth ();
1055- return IntWidth == 8 || IntWidth == 16 || IntWidth == 32 || IntWidth == 64 ;
1056- }
1057-
1058- InstructionCost PPCTTIImpl::getVPMemoryOpCost (unsigned Opcode, Type *Src,
1059- Align Alignment,
1060- unsigned AddressSpace,
1061- TTI::TargetCostKind CostKind,
1062- const Instruction *I) const {
1063- InstructionCost Cost = BaseT::getVPMemoryOpCost (Opcode, Src, Alignment,
1064- AddressSpace, CostKind, I);
1065- if (TLI->getValueType (DL, Src, true ) == MVT::Other)
1066- return Cost;
1067- // TODO: Handle other cost kinds.
1068- if (CostKind != TTI::TCK_RecipThroughput)
1069- return Cost;
1070-
1071- assert ((Opcode == Instruction::Load || Opcode == Instruction::Store) &&
1072- " Invalid Opcode" );
1073-
1074- auto *SrcVTy = dyn_cast<FixedVectorType>(Src);
1075- assert (SrcVTy && " Expected a vector type for VP memory operations" );
1076-
1077- if (hasActiveVectorLength (Opcode, Src, Alignment)) {
1078- std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost (SrcVTy);
1079-
1080- InstructionCost CostFactor =
1081- vectorCostAdjustmentFactor (Opcode, Src, nullptr );
1082- if (!CostFactor.isValid ())
1083- return InstructionCost::getMax ();
1084-
1085- InstructionCost Cost = LT.first * CostFactor;
1086- assert (Cost.isValid () && " Expected valid cost" );
1087-
1088- // On P9 but not on P10, if the op is misaligned then it will cause a
1089- // pipeline flush. Otherwise the VSX masked memops cost the same as unmasked
1090- // ones.
1091- const Align DesiredAlignment (16 );
1092- if (Alignment >= DesiredAlignment || ST->getCPUDirective () != PPC::DIR_PWR9)
1093- return Cost;
1094-
1095- // Since alignment may be under estimated, we try to compute the probability
1096- // that the actual address is aligned to the desired boundary. For example
1097- // an 8-byte aligned load is assumed to be actually 16-byte aligned half the
1098- // time, while a 4-byte aligned load has a 25% chance of being 16-byte
1099- // aligned.
1100- float AlignmentProb = ((float )Alignment.value ()) / DesiredAlignment.value ();
1101- float MisalignmentProb = 1.0 - AlignmentProb;
1102- return (MisalignmentProb * P9PipelineFlushEstimate) +
1103- (AlignmentProb * Cost.getValue ());
1104- }
1105-
1106- // Usually we should not get to this point, but the following is an attempt to
1107- // model the cost of legalization. Currently we can only lower intrinsics with
1108- // evl but no mask, on Power 9/10. Otherwise, we must scalarize.
1109- return getMaskedMemoryOpCost (Opcode, Src, Alignment, AddressSpace, CostKind);
1110- }
1111-
11121030bool PPCTTIImpl::supportsTailCallFor (const CallBase *CB) const {
11131031 return TLI->supportsTailCallFor (CB);
11141032}
0 commit comments