[llvm] [TTI] Introduce utilities for target costing of build & explode vector [NFC] (PR #85455)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 12:41:34 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff bb9ca8afc0bd5a1abb8ef3d0f5c8e4928c2f7f60 4628b586b398b863bb78f5acde48fcb719f5d41b -- llvm/include/llvm/CodeGen/BasicTTIImpl.h llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp llvm/lib/Target/X86/X86TargetTransformInfo.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 18e0896650..310be56c77 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -785,15 +785,15 @@ public:
InstructionCost getBuildVectorCost(VectorType *InTy,
const APInt &DemandedElts,
TTI::TargetCostKind CostKind) {
- return getScalarizationOverhead(InTy, DemandedElts, /*Insert=*/ true,
- /*Extract=*/ false, CostKind);
+ return getScalarizationOverhead(InTy, DemandedElts, /*Insert=*/true,
+ /*Extract=*/false, CostKind);
}
InstructionCost getExplodeVectorCost(VectorType *InTy,
const APInt &DemandedElts,
TTI::TargetCostKind CostKind) {
- return getScalarizationOverhead(InTy, DemandedElts, /*Insert=*/ false,
- /*Extract=*/ true, CostKind);
+ return getScalarizationOverhead(InTy, DemandedElts, /*Insert=*/false,
+ /*Extract=*/true, CostKind);
}
/// Helper wrapper for the DemandedElts variant of getScalarizationOverhead.
@@ -811,13 +811,13 @@ public:
InstructionCost getBuildVectorCost(VectorType *InTy,
TTI::TargetCostKind CostKind) {
- return getScalarizationOverhead(InTy, /*Insert=*/ true, /*Extract=*/ false,
+ return getScalarizationOverhead(InTy, /*Insert=*/true, /*Extract=*/false,
CostKind);
}
InstructionCost getExplodeVectorCost(VectorType *InTy,
TTI::TargetCostKind CostKind) {
- return getScalarizationOverhead(InTy, /*Insert=*/ false, /*Extract=*/ true,
+ return getScalarizationOverhead(InTy, /*Insert=*/false, /*Extract=*/true,
CostKind);
}
@@ -1840,8 +1840,8 @@ public:
if (RetVF.isVector() && !RetVF.isScalable()) {
ScalarizationCost = 0;
if (!RetTy->isVoidTy())
- ScalarizationCost += getBuildVectorCost(
- cast<VectorType>(RetTy), CostKind);
+ ScalarizationCost +=
+ getBuildVectorCost(cast<VectorType>(RetTy), CostKind);
ScalarizationCost +=
getOperandsScalarizationOverhead(Args, ICA.getArgTypes(), CostKind);
}
@@ -2313,9 +2313,8 @@ public:
return InstructionCost::getInvalid();
InstructionCost ScalarizationCost =
- SkipScalarizationCost
- ? ScalarizationCostPassed
- : getBuildVectorCost(RetVTy, CostKind);
+ SkipScalarizationCost ? ScalarizationCostPassed
+ : getBuildVectorCost(RetVTy, CostKind);
unsigned ScalarCalls = cast<FixedVectorType>(RetVTy)->getNumElements();
SmallVector<Type *, 4> ScalarTys;
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index 1e0bac8e54..4235b4fd79 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -1594,10 +1594,10 @@ InstructionCost ARMTTIImpl::getGatherScatterOpCost(
// elements plus the scalarization overhead. If masking is required then a lot
// of little blocks will be needed and potentially a scalarized p0 mask,
// greatly increasing the cost.
- InstructionCost ScalarCost =
- NumElems * LT.first + (VariableMask ? NumElems * 5 : 0) +
- BaseT::getBuildVectorCost(VTy, CostKind) +
- BaseT::getExplodeVectorCost(VTy, CostKind);
+ InstructionCost ScalarCost = NumElems * LT.first +
+ (VariableMask ? NumElems * 5 : 0) +
+ BaseT::getBuildVectorCost(VTy, CostKind) +
+ BaseT::getExplodeVectorCost(VTy, CostKind);
if (EltSize < 8 || Alignment < EltSize / 8)
return ScalarCost;
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
index 69ed6ae8d3..e2e9da67d4 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
@@ -924,8 +924,7 @@ InstructionCost SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
if (Opcode == Instruction::FPTrunc) {
if (SrcScalarBits == 128) // fp128 -> double/float + inserts of elements.
- return VF /*ldxbr/lexbr*/ +
- getBuildVectorCost(DstVecTy, CostKind);
+ return VF /*ldxbr/lexbr*/ + getBuildVectorCost(DstVecTy, CostKind);
else // double -> float
return VF / 2 /*vledb*/ + std::max(1U, VF / 4 /*vperm*/);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/85455
More information about the llvm-commits
mailing list