[llvm] SCEV: return std::nullopt for invalid TC (NFC) (PR #94162)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 02:28:14 PDT 2024
================
@@ -568,9 +568,10 @@ CacheCost::CacheCost(const LoopVectorTy &Loops, const LoopInfo &LI,
assert(!Loops.empty() && "Expecting a non-empty loop vector.");
for (const Loop *L : Loops) {
- unsigned TripCount = SE.getSmallConstantTripCount(L);
- TripCount = (TripCount == 0) ? DefaultTripCount : TripCount;
- TripCounts.push_back({L, TripCount});
+ std::optional<unsigned> TripCount = SE.getSmallConstantTripCount(L);
+ if (!TripCount)
+ TripCount = DefaultTripCount;
----------------
nikic wrote:
```suggestion
unsigned TripCount = SE.getSmallConstantTripCount(L).value_or(DefaultTripCount);
```
https://github.com/llvm/llvm-project/pull/94162
More information about the llvm-commits
mailing list