[llvm] [SimplifyCFG][PGO] Reuse existing `setBranchWeights` (PR #160629)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 30 10:47:34 PDT 2025


================
@@ -209,10 +209,10 @@ loop_exit:
 
 ; IR-LABEL: define void @func5_zero_branch_weight
 ; IR: entry:
-; IR:   br i1 %cmp1, label %loop_exit, label %loop_body.lr.ph, !prof [[PROF_FUNC5_0:![0-9]+]]
+; IR:   br i1 %cmp1, label %loop_exit, label %loop_body.lr.ph
----------------
mtrofin wrote:

> I think stricly speaking branch weights (0, 0) is equivalent to (1,1) or (2,2), no? 

Well, only problem is that `p(true) = branch_weight(true)/branch_weight(true)+branch_weight(false)` so `0/0` lol

I think we're in agreement about bias towards keeping what's passed around. I'd prefer the staged approach though, at minimum, easier for integration teams. Any pushback?

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


More information about the llvm-commits mailing list