[llvm] [LoopVectorize] Use predicated version of getSmallConstantMaxTripCount (PR #109928)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 01:41:08 PDT 2024
================
@@ -2447,6 +2451,9 @@ class PredicatedScalarEvolution {
/// The symbolic backedge taken count.
const SCEV *SymbolicMaxBackedgeCount = nullptr;
+
+ /// The constant max trip count for the loop.
+ std::optional<unsigned> SmallConstantMaxTripCount;
----------------
david-arm wrote:
The problem with that is the max trip count is measured as an `unsigned` value. I could potentially cache the intermediate result in the function:
```
unsigned ScalarEvolution::getSmallConstantMaxTripCount(
const Loop *L, SmallVectorImpl<const SCEVPredicate *> *Predicates) {
const auto *MaxExitCount =
Predicates ? getPredicatedConstantMaxBackedgeTakenCount(L, *Predicates)
: getConstantMaxBackedgeTakenCount(L);
return getConstantTripCount(dyn_cast<SCEVConstant>(MaxExitCount));
}
```
i.e. `MaxExitCount`, but then you still have to call `getConstantTripCount` each time so you see less benefit from caching it. That's why I chose to use `std::optional<unsigned>` - alternatively I could use a larger type such as `uint64_t` and treat UINT64_MAX as being equivalent to `not cached yet`.
https://github.com/llvm/llvm-project/pull/109928
More information about the llvm-commits
mailing list