[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
================
@@ -483,6 +483,14 @@ static bool mergeReplicateRegionsIntoSuccessors(VPlan &Plan) {
if (!Then1 || !Then2)
continue;
+ // The merged region is entered whenever either of the original regions was,
+ // so use the higher, i.e. more conservative, of their entry probabilities.
+ VPBranchOnMaskRecipe *Guard2 = Region2->getEntryBranchOnMask();
+ VPExecutionProbability Prob1 =
+ Region1->getEntryBranchOnMask()->getExecutionProbability();
+ if (!Prob1.isUnknown() && Guard2->getExecutionProbability() < Prob1)
+ Guard2->setExecutionProbability(Prob1, Plan.getContext());
----------------
fhahn wrote:
Added, but I couldn't get it to crash, II think this is handled by `<`.
https://github.com/llvm/llvm-project/pull/213143
More information about the llvm-commits
mailing list