[PATCH] D105113: [LV] NFCI: Do cost comparison on InstructionCost directly.
Sander de Smalen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 9 08:16:03 PDT 2021
sdesmalen updated this revision to Diff 357517.
sdesmalen added a comment.
Replaced `std::numeric_limits<InstructionCost::CostTy>::max()`
by `InstructionCost::getMax()`
As suggested in D105473 <https://reviews.llvm.org/D105473>.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105113/new/
https://reviews.llvm.org/D105113
Files:
llvm/include/llvm/Support/InstructionCost.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5983,8 +5983,8 @@
bool LoopVectorizationCostModel::isMoreProfitable(
const VectorizationFactor &A, const VectorizationFactor &B) const {
- InstructionCost::CostType CostA = *A.Cost.getValue();
- InstructionCost::CostType CostB = *B.Cost.getValue();
+ InstructionCost CostA = A.Cost;
+ InstructionCost CostB = B.Cost;
unsigned MaxTripCount = PSE.getSE()->getSmallConstantMaxTripCount(TheLoop);
@@ -5997,8 +5997,8 @@
// be PerIterationCost*floor(TC/VF) + Scalar remainder cost, and so is
// approximated with the per-lane cost below instead of using the tripcount
// as here.
- int64_t RTCostA = CostA * divideCeil(MaxTripCount, A.Width.getFixedValue());
- int64_t RTCostB = CostB * divideCeil(MaxTripCount, B.Width.getFixedValue());
+ auto RTCostA = CostA * divideCeil(MaxTripCount, A.Width.getFixedValue());
+ auto RTCostB = CostB * divideCeil(MaxTripCount, B.Width.getFixedValue());
return RTCostA < RTCostB;
}
@@ -6033,7 +6033,7 @@
// Ignore scalar width, because the user explicitly wants vectorization.
// Initialize cost to max so that VF = 2 is, at least, chosen during cost
// evaluation.
- ChosenFactor.Cost = std::numeric_limits<InstructionCost::CostType>::max();
+ ChosenFactor.Cost = InstructionCost::getMax();
}
for (const auto &i : VFCandidates) {
@@ -6569,10 +6569,14 @@
// A lambda that gets the register usage for the given type and VF.
const auto &TTICapture = TTI;
- auto GetRegUsage = [&TTICapture](Type *Ty, ElementCount VF) {
+ auto GetRegUsage = [&TTICapture](Type *Ty, ElementCount VF) -> unsigned {
if (Ty->isTokenTy() || !VectorType::isValidElementType(Ty))
return 0;
- return *TTICapture.getRegUsageForType(VectorType::get(Ty, VF)).getValue();
+ InstructionCost::CostType RegUsage =
+ *TTICapture.getRegUsageForType(VectorType::get(Ty, VF)).getValue();
+ assert(RegUsage >= 0 && RegUsage <= std::numeric_limits<unsigned>::max() &&
+ "Nonsensical values for register usage.");
+ return RegUsage;
};
for (unsigned int i = 0, s = IdxToInstr.size(); i < s; ++i) {
Index: llvm/include/llvm/Support/InstructionCost.h
===================================================================
--- llvm/include/llvm/Support/InstructionCost.h
+++ llvm/include/llvm/Support/InstructionCost.h
@@ -28,7 +28,7 @@
class InstructionCost {
public:
- using CostType = int;
+ using CostType = int64_t;
/// CostState describes the state of a cost.
enum CostState {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105113.357517.patch
Type: text/x-patch
Size: 2754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210709/efb94985/attachment.bin>
More information about the llvm-commits
mailing list