[llvm] [SLU][profcheck] Estimate branch weights in partial unswitch cases (PR #164035)

Joel E. Denny via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 23 11:28:52 PDT 2025


jdenny-ornl wrote:

As I understand it, the current PR strictly improves the accuracy of probabilities but falls short of achieving the BFI from before the transformation in two ways:
1. If it cannot prove the probability upper bound is less than .5, it offers no improvement.  It's this limitation that ensures this PR cannot worsen accuracy.
2. It does not adjust the probability of the unhoisted conditions to compensate for the probability added to the hoisted conditions.  The combined probabilities cause BFI inaccuracies, as demonstrated [in this test](https://github.com/llvm/llvm-project/pull/164035/files#r2456412199).

Am I understanding correctly?

If 2 can be addressed, I wonder if the limitation of 1 is necessary.  But I'm not sure how you would decide to split the probability between the hoisted conditions and the unhoisted conditions.

> Come to think of it, maybe a possibility is to use the BFI of the loop header before the transformation and calculate the BPI to preserve it.

It does seem like the original BFI should guide the above decision, if feasible.

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


More information about the llvm-commits mailing list