[llvm] [LV] Improve accuracy of branch weights in epilogue iteration check block (PR #152980)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 02:59:15 PDT 2025


================
@@ -7649,6 +7649,16 @@ EpilogueVectorizerEpilogueLoop::emitMinimumVectorEpilogueIterCountCheck(
     unsigned MainLoopStep = EPI.MainLoopUF * EPI.MainLoopVF.getKnownMinValue();
     unsigned EpilogueLoopStep =
         EPI.EpilogueUF * EPI.EpilogueVF.getKnownMinValue();
+    // When one of the vector loops is scalable and the other isn't, we can use
+    // the estimated value of vscale to improve the accuracy.
+    if (EPI.MainLoopVF.isScalable() != EPI.EpilogueVF.isScalable()) {
----------------
lukel97 wrote:

If both loops are scalable, would multiplying them by vscale as well be a no-op?

If so should we just always multiply the scalable VFs by vscale? I.e. just use `estimateElementCount` instead

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


More information about the llvm-commits mailing list