Skip to content

Commit 9623220

Browse files
committed
Address review comments
1 parent 28e3bc6 commit 9623220

File tree

10 files changed

+41
-37
lines changed

10 files changed

+41
-37
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,12 +1513,12 @@ class TargetTransformInfo {
15131513
unsigned Index = -1) const;
15141514

15151515
/// \return The expected cost of inserting or extracting a lane that is \p
1516-
/// Index from the end of a vector, i.e. the mathematical expression for
1517-
/// the lane is (VF - 1 - Index). This is required for scalable vectors where
1518-
/// the exact lane index is unknown at compile time.
1519-
LLVM_ABI InstructionCost
1520-
getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
1521-
TTI::TargetCostKind CostKind, unsigned Index) const;
1516+
/// Index elements from the end of a vector, i.e. the mathematical expression
1517+
/// for the lane is (VF - 1 - Index). This is required for scalable vectors
1518+
/// where the exact lane index is unknown at compile time.
1519+
LLVM_ABI InstructionCost getIndexedVectorInstrCostFromEnd(
1520+
unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind,
1521+
unsigned Index) const;
15221522

15231523
/// \return The expected cost of aggregate inserts and extracts. This is
15241524
/// used when the instruction is not available; a typical use case is to

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,9 @@ class TargetTransformInfoImplBase {
810810
}
811811

812812
virtual InstructionCost
813-
getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
814-
TTI::TargetCostKind CostKind,
815-
unsigned Index) const {
813+
getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
814+
TTI::TargetCostKind CostKind,
815+
unsigned Index) const {
816816
return 1;
817817
}
818818

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
14441444
Op1);
14451445
}
14461446

1447-
InstructionCost getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
1448-
TTI::TargetCostKind CostKind,
1449-
unsigned Index) const override {
1447+
InstructionCost
1448+
getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
1449+
TTI::TargetCostKind CostKind,
1450+
unsigned Index) const override {
14501451
unsigned NewIndex = -1;
14511452
if (auto *FVTy = dyn_cast<FixedVectorType>(Val)) {
14521453
assert(Index < FVTy->getNumElements() &&

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,12 +1130,11 @@ TargetTransformInfo::getVectorInstrCost(const Instruction &I, Type *Val,
11301130
return Cost;
11311131
}
11321132

1133-
InstructionCost
1134-
TargetTransformInfo::getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
1135-
TTI::TargetCostKind CostKind,
1136-
unsigned Index) const {
1133+
InstructionCost TargetTransformInfo::getIndexedVectorInstrCostFromEnd(
1134+
unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind,
1135+
unsigned Index) const {
11371136
InstructionCost Cost =
1138-
TTIImpl->getVectorInstrCostFromEnd(Opcode, Val, CostKind, Index);
1137+
TTIImpl->getIndexedVectorInstrCostFromEnd(Opcode, Val, CostKind, Index);
11391138
assert(Cost >= 0 && "TTI should not produce negative costs!");
11401139
return Cost;
11411140
}

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3987,11 +3987,12 @@ InstructionCost AArch64TTIImpl::getVectorInstrCost(const Instruction &I,
39873987
}
39883988

39893989
InstructionCost
3990-
AArch64TTIImpl::getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
3991-
TTI::TargetCostKind CostKind,
3992-
unsigned Index) const {
3993-
if (auto *FixedVecTy = dyn_cast<FixedVectorType>(Val))
3994-
return BaseT::getVectorInstrCostFromEnd(Opcode, Val, CostKind, Index);
3990+
AArch64TTIImpl::getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
3991+
TTI::TargetCostKind CostKind,
3992+
unsigned Index) const {
3993+
if (isa<FixedVectorType>(Val))
3994+
return BaseT::getIndexedVectorInstrCostFromEnd(Opcode, Val, CostKind,
3995+
Index);
39953996

39963997
// This typically requires both while and lastb instructions in order
39973998
// to extract the last element. If this is in a loop the while

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,10 @@ class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
220220
TTI::TargetCostKind CostKind,
221221
unsigned Index) const override;
222222

223-
InstructionCost getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
224-
TTI::TargetCostKind CostKind,
225-
unsigned Index) const override;
223+
InstructionCost
224+
getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
225+
TTI::TargetCostKind CostKind,
226+
unsigned Index) const override;
226227

227228
InstructionCost
228229
getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,11 +2416,12 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
24162416
}
24172417

24182418
InstructionCost
2419-
RISCVTTIImpl::getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
2420-
TTI::TargetCostKind CostKind,
2421-
unsigned Index) const {
2422-
if (auto *FixedVecTy = dyn_cast<FixedVectorType>(Val))
2423-
return BaseT::getVectorInstrCostFromEnd(Opcode, Val, CostKind, Index);
2419+
RISCVTTIImpl::getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
2420+
TTI::TargetCostKind CostKind,
2421+
unsigned Index) const {
2422+
if (isa<FixedVectorType>(Val))
2423+
return BaseT::getIndexedVectorInstrCostFromEnd(Opcode, Val, CostKind,
2424+
Index);
24242425

24252426
// TODO: This code replicates what LoopVectorize.cpp used to do when asking
24262427
// for the cost of extracting the last lane of a scalable vector. It probably

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ class RISCVTTIImpl final : public BasicTTIImplBase<RISCVTTIImpl> {
243243
unsigned Index, const Value *Op0,
244244
const Value *Op1) const override;
245245

246-
InstructionCost getVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
247-
TTI::TargetCostKind CostKind,
248-
unsigned Index) const override;
246+
InstructionCost
247+
getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val,
248+
TTI::TargetCostKind CostKind,
249+
unsigned Index) const override;
249250

250251
InstructionCost getArithmeticInstrCost(
251252
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5301,8 +5301,8 @@ LoopVectorizationCostModel::getUniformMemOpCost(Instruction *I,
53015301
TTI.getAddressComputationCost(PtrTy, nullptr, nullptr, CostKind) +
53025302
TTI.getMemoryOpCost(Instruction::Store, ValTy, Alignment, AS, CostKind);
53035303
if (!IsLoopInvariantStoreValue)
5304-
Cost += TTI.getVectorInstrCostFromEnd(Instruction::ExtractElement, VectorTy,
5305-
CostKind, 0);
5304+
Cost += TTI.getIndexedVectorInstrCostFromEnd(Instruction::ExtractElement,
5305+
VectorTy, CostKind, 0);
53065306
return Cost;
53075307
}
53085308

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,8 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
10141014
case VPInstruction::ExtractLastElement: {
10151015
// Add on the cost of extracting the element.
10161016
auto *VecTy = toVectorTy(Ctx.Types.inferScalarType(getOperand(0)), VF);
1017-
return Ctx.TTI.getVectorInstrCostFromEnd(Instruction::ExtractElement, VecTy,
1018-
Ctx.CostKind, 0);
1017+
return Ctx.TTI.getIndexedVectorInstrCostFromEnd(Instruction::ExtractElement,
1018+
VecTy, Ctx.CostKind, 0);
10191019
}
10201020
case VPInstruction::ExtractPenultimateElement:
10211021
if (VF == ElementCount::getScalable(1))

0 commit comments

Comments
 (0)