[llvm] ee8959d - [Analysis] Use std::optional in ScalarEvolution.cpp (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 25 11:25:52 PST 2022
Author: Kazu Hirata
Date: 2022-11-25T11:25:45-08:00
New Revision: ee8959d09894f2494c4c6928a6904ac0f45b9fe7
URL: https://github.com/llvm/llvm-project/commit/ee8959d09894f2494c4c6928a6904ac0f45b9fe7
DIFF: https://github.com/llvm/llvm-project/commit/ee8959d09894f2494c4c6928a6904ac0f45b9fe7.diff
LOG: [Analysis] Use std::optional in ScalarEvolution.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 6b20f08ad44e..8ce175e20bff 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -126,6 +126,7 @@
#include <map>
#include <memory>
#include <numeric>
+#include <optional>
#include <tuple>
#include <utility>
#include <vector>
@@ -713,7 +714,7 @@ CompareValueComplexity(EquivalenceClasses<const Value *> &EqCacheValue,
// more efficient.
// If the max analysis depth was reached, return None, assuming we do not know
// if they are equivalent for sure.
-static Optional<int>
+static std::optional<int>
CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
EquivalenceClasses<const Value *> &EqCacheValue,
const LoopInfo *const LI, const SCEV *LHS,
@@ -5126,7 +5127,7 @@ struct BinaryOp {
} // end anonymous namespace
/// Try to map \p V into a BinaryOp, and return \c None on failure.
-static Optional<BinaryOp> MatchBinaryOp(Value *V, DominatorTree &DT) {
+static std::optional<BinaryOp> MatchBinaryOp(Value *V, DominatorTree &DT) {
auto *Op = dyn_cast<Operator>(V);
if (!Op)
return None;
@@ -6954,7 +6955,7 @@ ConstantRange ScalarEvolution::getRangeViaFactoring(const SCEV *Start,
explicit SelectPattern(ScalarEvolution &SE, unsigned BitWidth,
const SCEV *S) {
- Optional<unsigned> CastOp;
+ std::optional<unsigned> CastOp;
APInt Offset(BitWidth, 0);
assert(SE.getTypeSizeInBits(S->getType()) == BitWidth &&
@@ -8158,7 +8159,7 @@ unsigned ScalarEvolution::getSmallConstantTripMultiple(const Loop *L) {
SmallVector<BasicBlock *, 8> ExitingBlocks;
L->getExitingBlocks(ExitingBlocks);
- Optional<unsigned> Res;
+ std::optional<unsigned> Res;
for (auto *ExitingBB : ExitingBlocks) {
unsigned Multiple = getSmallConstantTripMultiple(L, ExitingBB);
if (!Res)
@@ -9199,7 +9200,7 @@ ScalarEvolution::ExitLimit ScalarEvolution::computeShiftCompareExitLimit(
// above) in PNOut and the opcode of the shift operation in OpCodeOut.
auto MatchShiftRecurrence =
[&](Value *V, PHINode *&PNOut, Instruction::BinaryOps &OpCodeOut) {
- Optional<Instruction::BinaryOps> PostShiftOpCode;
+ std::optional<Instruction::BinaryOps> PostShiftOpCode;
{
Instruction::BinaryOps OpC;
@@ -9996,7 +9997,7 @@ static const SCEV *SolveLinEquationWithOverflow(const APInt &A, const SCEV *B,
/// coefficients.
/// This function returns None if the addrec coefficients are not compile-
/// time constants.
-static Optional<std::tuple<APInt, APInt, APInt, APInt, unsigned>>
+static std::optional<std::tuple<APInt, APInt, APInt, APInt, unsigned>>
GetQuadraticEquation(const SCEVAddRecExpr *AddRec) {
assert(AddRec->getNumOperands() == 3 && "This is not a quadratic chrec!");
const SCEVConstant *LC = dyn_cast<SCEVConstant>(AddRec->getOperand(0));
More information about the llvm-commits
mailing list