[llvm] [SimplifyCFG] Probabilities associated with same condition are constant (PR #155734)
    Mircea Trofin via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Sep  3 20:16:40 PDT 2025
    
    
  
================
@@ -4808,23 +4808,12 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI,
       SelectInst *NV = cast<SelectInst>(
           Builder.CreateSelect(PBICond, PBIV, BIV, PBIV->getName() + ".mux"));
       PN.setIncomingValue(PBBIdx, NV);
-      // Although the select has the same condition as PBI, the original branch
-      // weights for PBI do not apply to the new select because the select's
-      // 'logical' edges are incoming edges of the phi that is eliminated, not
-      // the outgoing edges of PBI.
+      // The select has the same condition as PBI. The probabilities don't
----------------
mtrofin wrote:
> the branch probability is control flow dependent
Ah, true. Got it.
> The dillema is that[...]
Here, the select itself is created in the same BB as the condition it governs it (see `Builder`, lines 4747, 4808). But ack on the overall issue. I'm thinking that ultimately, the general case here becomes a question for the next phase - where we look for profile value correctness. Potentially we could track the probabilities of values associated with branches, at least for validation, if not for derivation, too.
https://github.com/llvm/llvm-project/pull/155734
    
    
More information about the llvm-commits
mailing list