[llvm] [LV] capture branch weights for constant trip counts (PR #175096)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 23 08:28:35 PST 2026


================
@@ -1692,17 +1696,33 @@ void LoopVectorizationPlanner::updateLoopMetadataAndProfileInfo(
   // For scalable vectorization we can't know at compile time how many
   // iterations of the loop are handled in one vector iteration, so instead
   // use the value of vscale used for tuning.
-  if (!OrigAverageTripCount)
-    return;
-  // Calculate number of iterations in unrolled loop.
-  unsigned AverageVectorTripCount = *OrigAverageTripCount / EstimatedVFxUF;
-  // Calculate number of iterations for remainder loop.
-  unsigned RemainderAverageTripCount = *OrigAverageTripCount % EstimatedVFxUF;
-
+  unsigned AverageVectorTripCount = 0;
+  unsigned RemainderAverageTripCount = 0;
+  auto EC = VectorLoop->getLoopPreheader()->getParent()->getEntryCount();
+  auto IsProfiled = EC && EC->getCount();
----------------
boomanaiden154 wrote:

Nit: This could just be bool and that would improve readability.

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


More information about the llvm-commits mailing list