[llvm] [LV] Change loops' interleave count computation (PR #73766)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 06:49:29 PST 2023
================
@@ -5737,10 +5741,15 @@ LoopVectorizationCostModel::selectInterleaveCount(ElementCount VF,
// the InterleaveCount as if vscale is '1', although if some information about
// the vector is known (e.g. min vector size), we can make a better decision.
if (BestKnownTC) {
- MaxInterleaveCount =
- std::min(*BestKnownTC / VF.getKnownMinValue(), MaxInterleaveCount);
- // Make sure MaxInterleaveCount is greater than 0.
- MaxInterleaveCount = std::max(1u, MaxInterleaveCount);
+ if (InterleaveSmallLoopScalarReduction ||
+ (*BestKnownTC % VF.getKnownMinValue() == 0))
----------------
david-arm wrote:
I think it makes sense to make a better guess of the runtime VF here by doing
```
unsigned EstimatedVF = VF.getKnownMinValue();
if (std::optional<unsigned> VScale = getVScaleForTuning())
EstimatedVF *= *VScale;
```
so that you're algorithm is doing what you expect for scalable vectors. It's possible that vscale may be quite large for the CPU we're targetting.
https://github.com/llvm/llvm-project/pull/73766
More information about the llvm-commits
mailing list