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

Nilanjana Basu via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 17:16:03 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),
----------------
nilanjana87 wrote:

Created 2 separate PRs on which this PR depends. 
1. https://github.com/llvm/llvm-project/pull/70272 - pre-committed additional tests
2. https://github.com/llvm/llvm-project/pull/70141 - part 1 of the patch that changes MaxInterleaveCount for a subset of cases. Added an additional condition of keeping MaxInterleaveCount same as before when the trip count is divisible by the VF, since that would generally mean that the epilogue loop is not required. 

Note that in the case of PGO-driven trip count, the trip count maybe an average over different TCs & not an exact one, allowing an epilogue loop to run even then - this case is not handled in this patch.

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


More information about the llvm-commits mailing list