[llvm] [LV] Change getSmallBestKnownTC to return an ElementCount (NFC) (PR #141793)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 02:50:24 PDT 2025
================
@@ -427,24 +427,24 @@ static bool hasIrregularType(Type *Ty, const DataLayout &DL) {
/// 2) Returns expected trip count according to profile data if any.
/// 3) Returns upper bound estimate if known, and if \p CanUseConstantMax.
/// 4) Returns std::nullopt if all of the above failed.
-static std::optional<unsigned>
+static std::optional<ElementCount>
getSmallBestKnownTC(PredicatedScalarEvolution &PSE, Loop *L,
bool CanUseConstantMax = true) {
----------------
paulwalker-arm wrote:
It's part of a chain so I'll see about pulling it out.
My objective is to allow multiples of vscale to be returned so that when vectorising a loop of the form `for (int i = 0; i < llvm.vscale() * N; ++i)` using a scalable VF the vectoriser can make sensible interleaving decisions. For example, today for the N=1 case LoopVectorize picks the default interleaving factor of 2 which means we never enter the vector loop.
In the same vein, representing vscale base trip counts also allows the vectoriser to better reason about whether the scalar loop becomes dead after vectorisation.
I did investigate the possibility of changing the existing interface but felt the impact was too high, especially as the majority of uses do not care about vscale based trip counts.
https://github.com/llvm/llvm-project/pull/141793
More information about the llvm-commits
mailing list