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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 03:02:31 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()) {
----------------
david-arm wrote:

The `EPI.MainLoopVF.isScalable() != EPI.EpilogueVF.isScalable()` check guarantees that only one of them is scalable. For the case when they're both scalable the weights are correct and I was trying to avoid doing unnecessary work. I could just always multiply by vscale and call `estimateElementCount` instead if you prefer?

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


More information about the llvm-commits mailing list