[llvm] [VPlan] Preserve branch weights from VPlan0 through to codegen. (PR #213143)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 06:25:18 PDT 2026


================
@@ -1055,6 +1058,77 @@ SmallVector<VPUser *> vputils::collectUsersRecursively(VPValue *V) {
   return Users.takeVector();
 }
 
+/// Returns the probability of reaching each unique successor of \p VPBB, taken
+/// from the branch weights recorded on its terminator, or unknown if not
+/// available. See llvm::getBranchProbability in
+/// llvm/Transforms/Utils/LoopUtils.h for the IR version.
+static SmallVector<std::pair<const VPBasicBlock *, BranchProbability>, 2>
+getSuccessorProbabilities(const VPBasicBlock *VPBB) {
+  ArrayRef<VPBlockBase *> Successors = VPBB->getSuccessors();
+  // With a single successor the edge is always taken and needs no weights.
+  if (Successors.size() == 1)
+    return {{cast<VPBasicBlock>(Successors[0]), BranchProbability::getOne()}};
----------------
fhahn wrote:

done thanks

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


More information about the llvm-commits mailing list