[llvm] 77b202f - [RISCV] Rename getVectorImmCost to getStoreImmCost [nfc]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 27 08:22:33 PDT 2022
Author: Philip Reames
Date: 2022-09-27T08:22:13-07:00
New Revision: 77b202f974faa82679d9984aeef58355dc80ba80
URL: https://github.com/llvm/llvm-project/commit/77b202f974faa82679d9984aeef58355dc80ba80
DIFF: https://github.com/llvm/llvm-project/commit/77b202f974faa82679d9984aeef58355dc80ba80.diff
LOG: [RISCV] Rename getVectorImmCost to getStoreImmCost [nfc]
My original intent had been to reuse this for arithmetic instructions as well, but due to the availability of a immediate splat encoding there, we will need different heuristics. So specialize the existing code for the store case.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 88c5931d2d886..94852c53fe3c0 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -656,15 +656,21 @@ InstructionCost RISCVTTIImpl::getExtendedReductionCost(
getArithmeticReductionCost(Opcode, ValTy, FMF, CostKind);
}
-InstructionCost RISCVTTIImpl::getVectorImmCost(VectorType *VecTy,
- TTI::OperandValueInfo OpInfo,
- TTI::TargetCostKind CostKind) {
+InstructionCost RISCVTTIImpl::getStoreImmCost(Type *Ty,
+ TTI::OperandValueInfo OpInfo,
+ TTI::TargetCostKind CostKind) {
assert(OpInfo.isConstant() && "non constant operand?");
+ if (!isa<VectorType>(Ty))
+ // FIXME: We need to account for immediate materialization here, but doing
+ // a decent job requires more knowledge about the immediate than we
+ // currently have here.
+ return 0;
+
APInt PseudoAddr = APInt::getAllOnes(DL.getPointerSizeInBits());
// Add a cost of address load + the cost of the vector load.
return RISCVMatInt::getIntMatCost(PseudoAddr, DL.getPointerSizeInBits(),
getST()->getFeatureBits()) +
- getMemoryOpCost(Instruction::Load, VecTy, DL.getABITypeAlign(VecTy),
+ getMemoryOpCost(Instruction::Load, Ty, DL.getABITypeAlign(Ty),
/*AddressSpace=*/0, CostKind);
}
@@ -676,8 +682,8 @@ InstructionCost RISCVTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
TTI::OperandValueInfo OpInfo,
const Instruction *I) {
InstructionCost Cost = 0;
- if (Opcode == Instruction::Store && isa<VectorType>(Src) && OpInfo.isConstant())
- Cost += getVectorImmCost(cast<VectorType>(Src), OpInfo, CostKind);
+ if (Opcode == Instruction::Store && OpInfo.isConstant())
+ Cost += getStoreImmCost(Src, OpInfo, CostKind);
return Cost + BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
CostKind, OpInfo, I);
}
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
index b49bafb7db941..704d0dbdffaff 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
@@ -51,11 +51,10 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
TLI(ST->getTargetLowering()) {}
- /// Return the cost of materializing a vector immediate, assuming it does
- /// not get folded into the using instruction(s).
- InstructionCost getVectorImmCost(VectorType *VecTy,
- TTI::OperandValueInfo OpInfo,
- TTI::TargetCostKind CostKind);
+ /// Return the cost of materializing an immediate for a value operand of
+ /// a store instruction.
+ InstructionCost getStoreImmCost(Type *VecTy, TTI::OperandValueInfo OpInfo,
+ TTI::TargetCostKind CostKind);
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty,
TTI::TargetCostKind CostKind);
More information about the llvm-commits
mailing list