Skip to content

Commit 071a6fe

Browse files
authored
[TTI] Remove PPC hasActiveVectorLength impl, simplify interface (NFC). (#142310)
PPCTTIImpl defines hasActiveVectorLength and also getVPMemoryOpCost, but they appear unused (i.e. no changes to tests). Remove them, as they complicate the interface for hasActiveVectorLength. This simplifies the only use in LV as now no placeholder values need to be passed. PR: #142310
1 parent dfe4d44 commit 071a6fe

File tree

8 files changed

+11
-114
lines changed

8 files changed

+11
-114
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,11 +1850,9 @@ class TargetTransformInfo {
18501850
/// \name Vector Predication Information
18511851
/// @{
18521852
/// Whether the target supports the %evl parameter of VP intrinsic efficiently
1853-
/// in hardware, for the given opcode and type/alignment. (see LLVM Language
1854-
/// Reference - "Vector Predication Intrinsics").
1855-
/// Use of %evl is discouraged when that is not the case.
1856-
LLVM_ABI bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
1857-
Align Alignment) const;
1853+
/// in hardware. (see LLVM Language Reference - "Vector Predication
1854+
/// Intrinsics"). Use of %evl is discouraged when that is not the case.
1855+
LLVM_ABI bool hasActiveVectorLength() const;
18581856

18591857
/// Return true if sinking I's operands to the same basic block as I is
18601858
/// profitable, e.g. because the operands can be folded into a target

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,7 @@ class TargetTransformInfoImplBase {
11081108

11091109
virtual bool enableScalableVectorization() const { return false; }
11101110

1111-
virtual bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
1112-
Align Alignment) const {
1113-
return false;
1114-
}
1111+
virtual bool hasActiveVectorLength() const { return false; }
11151112

11161113
virtual bool isProfitableToSinkOperands(Instruction *I,
11171114
SmallVectorImpl<Use *> &Ops) const {

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,9 +1454,8 @@ bool TargetTransformInfo::enableScalableVectorization() const {
14541454
return TTIImpl->enableScalableVectorization();
14551455
}
14561456

1457-
bool TargetTransformInfo::hasActiveVectorLength(unsigned Opcode, Type *DataType,
1458-
Align Alignment) const {
1459-
return TTIImpl->hasActiveVectorLength(Opcode, DataType, Alignment);
1457+
bool TargetTransformInfo::hasActiveVectorLength() const {
1458+
return TTIImpl->hasActiveVectorLength();
14601459
}
14611460

14621461
bool TargetTransformInfo::isProfitableToSinkOperands(

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
11121030
bool PPCTTIImpl::supportsTailCallFor(const CallBase *CB) const {
11131031
return TLI->supportsTailCallFor(CB);
11141032
}

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@ class PPCTTIImpl final : public BasicTTIImplBase<PPCTTIImpl> {
148148
const Function *Callee) const override;
149149
bool areTypesABICompatible(const Function *Caller, const Function *Callee,
150150
const ArrayRef<Type *> &Types) const override;
151-
bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
152-
Align Alignment) const override;
153-
InstructionCost
154-
getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
155-
unsigned AddressSpace, TTI::TargetCostKind CostKind,
156-
const Instruction *I = nullptr) const override;
157151
bool supportsTailCallFor(const CallBase *CB) const override;
158152

159153
private:

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ RISCVTTIImpl::getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx,
282282
return TTI::TCC_Free;
283283
}
284284

285-
bool RISCVTTIImpl::hasActiveVectorLength(unsigned, Type *DataTy, Align) const {
285+
bool RISCVTTIImpl::hasActiveVectorLength() const {
286286
return ST->hasVInstructions();
287287
}
288288

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,12 @@ class RISCVTTIImpl final : public BasicTTIImplBase<RISCVTTIImpl> {
9090

9191
/// \name EVL Support for predicated vectorization.
9292
/// Whether the target supports the %evl parameter of VP intrinsic efficiently
93-
/// in hardware, for the given opcode and type/alignment. (see LLVM Language
94-
/// Reference - "Vector Predication Intrinsics",
93+
/// in hardware. (see LLVM Language Reference - "Vector Predication
94+
/// Intrinsics",
9595
/// https://llvm.org/docs/LangRef.html#vector-predication-intrinsics and
9696
/// "IR-level VP intrinsics",
9797
/// https://llvm.org/docs/Proposals/VectorPredication.html#ir-level-vp-intrinsics).
98-
/// \param Opcode the opcode of the instruction checked for predicated version
99-
/// support.
100-
/// \param DataType the type of the instruction with the \p Opcode checked for
101-
/// prediction support.
102-
/// \param Alignment the alignment for memory access operation checked for
103-
/// predicated version support.
104-
bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
105-
Align Alignment) const override;
98+
bool hasActiveVectorLength() const override;
10699

107100
TargetTransformInfo::PopcntSupportKind
108101
getPopcntSupport(unsigned TyWidth) const override;

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,11 +1377,9 @@ class LoopVectorizationCostModel {
13771377
if (ForceTailFoldingStyle != TailFoldingStyle::DataWithEVL)
13781378
return;
13791379
// Override forced styles if needed.
1380-
// FIXME: use actual opcode/data type for analysis here.
13811380
// FIXME: Investigate opportunity for fixed vector factor.
13821381
bool EVLIsLegal = UserIC <= 1 && IsScalableVF &&
1383-
TTI.hasActiveVectorLength(0, nullptr, Align()) &&
1384-
!EnableVPlanNativePath;
1382+
TTI.hasActiveVectorLength() && !EnableVPlanNativePath;
13851383
if (!EVLIsLegal) {
13861384
// If for some reason EVL mode is unsupported, fallback to
13871385
// DataWithoutLaneMask to try to vectorize the loop with folded tail

0 commit comments

Comments
 (0)