[llvm] 08bb121 - [TTI] getCommonMaskedMemoryOpCost - pull out repeated getNumElements calls. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 5 05:16:48 PDT 2024
Author: Simon Pilgrim
Date: 2024-04-05T13:16:27+01:00
New Revision: 08bb121835be432ac52372f92845950628ce9a4a
URL: https://github.com/llvm/llvm-project/commit/08bb121835be432ac52372f92845950628ce9a4a
DIFF: https://github.com/llvm/llvm-project/commit/08bb121835be432ac52372f92845950628ce9a4a.diff
LOG: [TTI] getCommonMaskedMemoryOpCost - pull out repeated getNumElements calls. NFC.
Added:
Modified:
llvm/include/llvm/CodeGen/BasicTTIImpl.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 92fa726c31df14..241529e22538a7 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -215,22 +215,23 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return InstructionCost::getInvalid();
auto *VT = cast<FixedVectorType>(DataTy);
+ unsigned VF = VT->getNumElements();
+
// Assume the target does not have support for gather/scatter operations
// and provide a rough estimate.
//
// First, compute the cost of the individual memory operations.
InstructionCost AddrExtractCost =
IsGatherScatter
- ? getVectorInstrCost(Instruction::ExtractElement,
- FixedVectorType::get(
- PointerType::get(VT->getElementType(), 0),
- VT->getNumElements()),
- CostKind, -1, nullptr, nullptr)
+ ? getVectorInstrCost(
+ Instruction::ExtractElement,
+ FixedVectorType::get(
+ PointerType::get(VT->getElementType(), 0), VF),
+ CostKind, -1, nullptr, nullptr)
: 0;
InstructionCost LoadCost =
- VT->getNumElements() *
- (AddrExtractCost +
- getMemoryOpCost(Opcode, VT->getElementType(), Alignment, 0, CostKind));
+ VF * (AddrExtractCost + getMemoryOpCost(Opcode, VT->getElementType(),
+ Alignment, 0, CostKind));
// Next, compute the cost of packing the result in a vector.
InstructionCost PackingCost =
@@ -246,11 +247,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
// operations accurately is quite
diff icult and the current solution
// provides a very rough estimate only.
ConditionalCost =
- VT->getNumElements() *
+ VF *
(getVectorInstrCost(
Instruction::ExtractElement,
- FixedVectorType::get(Type::getInt1Ty(DataTy->getContext()),
- VT->getNumElements()),
+ FixedVectorType::get(Type::getInt1Ty(DataTy->getContext()), VF),
CostKind, -1, nullptr, nullptr) +
getCFInstrCost(Instruction::Br, CostKind) +
getCFInstrCost(Instruction::PHI, CostKind));
More information about the llvm-commits
mailing list