Skip to content

Commit

Permalink
[Transforms/Vectorize] llvm::Optional => std::optional
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Dec 12, 2022
1 parent 34dac67 commit 1ec11d2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 55 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
Expand Up @@ -297,7 +297,7 @@ class LoopVectorizationPlanner {

/// Plan how to best vectorize, return the best VF and its cost, or
/// std::nullopt if vectorization and interleaving should be avoided up front.
Optional<VectorizationFactor> plan(ElementCount UserVF, unsigned UserIC);
std::optional<VectorizationFactor> plan(ElementCount UserVF, unsigned UserIC);

/// Use the VPlan-native path to plan how to best vectorize, return the best
/// VF and its cost.
Expand Down
14 changes: 8 additions & 6 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Expand Up @@ -402,7 +402,8 @@ static Constant *getSignedIntOrFpConstant(Type *Ty, int64_t C) {
/// 2) Returns expected trip count according to profile data if any.
/// 3) Returns upper bound estimate if it is known.
/// 4) Returns std::nullopt if all of the above failed.
static Optional<unsigned> getSmallBestKnownTC(ScalarEvolution &SE, Loop *L) {
static std::optional<unsigned> getSmallBestKnownTC(ScalarEvolution &SE,
Loop *L) {
// Check if exact trip count is known.
if (unsigned ExpectedTC = SE.getSmallConstantTripCount(L))
return ExpectedTC;
Expand Down Expand Up @@ -1636,7 +1637,7 @@ class LoopVectorizationCostModel {

/// Return the cost of instructions in an inloop reduction pattern, if I is
/// part of that pattern.
Optional<InstructionCost>
std::optional<InstructionCost>
getReductionPatternCost(Instruction *I, ElementCount VF, Type *VectorTy,
TTI::TargetCostKind CostKind);

Expand Down Expand Up @@ -6556,7 +6557,8 @@ LoopVectorizationCostModel::getInterleaveGroupCost(Instruction *I,
return Cost;
}

Optional<InstructionCost> LoopVectorizationCostModel::getReductionPatternCost(
std::optional<InstructionCost>
LoopVectorizationCostModel::getReductionPatternCost(
Instruction *I, ElementCount VF, Type *Ty, TTI::TargetCostKind CostKind) {
using namespace llvm::PatternMatch;
// Early exit for no inloop reductions
Expand Down Expand Up @@ -6725,7 +6727,7 @@ Optional<InstructionCost> LoopVectorizationCostModel::getReductionPatternCost(
}
}

return I == RetI ? Optional<InstructionCost>(BaseCost) : std::nullopt;
return I == RetI ? std::optional<InstructionCost>(BaseCost) : std::nullopt;
}

InstructionCost
Expand Down Expand Up @@ -7506,7 +7508,7 @@ LoopVectorizationPlanner::planInVPlanNativePath(ElementCount UserVF) {
return VectorizationFactor::Disabled();
}

Optional<VectorizationFactor>
std::optional<VectorizationFactor>
LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
assert(OrigLoop->isInnermost() && "Inner loop expected.");
FixedScalableVFPair MaxFactors = CM.computeMaxVF(UserVF, UserIC);
Expand Down Expand Up @@ -10322,7 +10324,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
unsigned UserIC = Hints.getInterleave();

// Plan how to best vectorize, return the best VF and its cost.
Optional<VectorizationFactor> MaybeVF = LVP.plan(UserVF, UserIC);
std::optional<VectorizationFactor> MaybeVF = LVP.plan(UserVF, UserIC);

VectorizationFactor VF = VectorizationFactor::Disabled();
unsigned IC = 1;
Expand Down

0 comments on commit 1ec11d2

Please sign in to comment.