[llvm] [LV] Relax high loop trip count threshold for deciding to interleave a loop (PR #67725)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 04:09:12 PDT 2023


================
@@ -5755,8 +5745,12 @@ 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);
+    if (InterleaveSmallLoopScalarReduction)
+      MaxInterleaveCount =
+          std::min(*BestKnownTC / VF.getKnownMinValue(), MaxInterleaveCount);
+    else
+      MaxInterleaveCount = std::min(*BestKnownTC / (VF.getKnownMinValue() * 2),
----------------
david-arm wrote:

It feels like there are two independent changes in this patch that don't need to be tied together. Logically it looks like you could split these up into two patches:

1. For the general case (i.e. trip counts >= TinyTripCountInterleaveThreshold) change the MaxInterleaveCount so that we execute at least two vector loop iterations. Followed by ...
2. A patch to remove TinyTripCountInterleaveThreshold and add the InterleaveSmallLoopScalarReduction case here.

If you can split these up into two patches it would be easier for reviewers to see what test changes correspond to which code change. At the moment it's quite a large patch! What do you think?

https://github.com/llvm/llvm-project/pull/67725


More information about the llvm-commits mailing list