[llvm] [CodeGen] [EarlyIfConversion] Prioritize conversion of hard to predict branches (PR #174457)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 12 02:55:26 PST 2026


https://github.com/fhahn commented:

> The key point is that the more program time that passes between when a value has been loaded from memory to when we reach the branch, the more chance it has to affect control flow elsewhere which can then be correlated with the direction of the branch we are currently trying to predict.
> 
> Of course there is a heuristic, so there are many counter examples we can come of with - but this aligns with what we have seen experimentally.

Could you provide some data on how this impacts the number of branches converted on a larger set of workloads? That may be helpful to better understand the scope.


Currently this would consider something like `x[i] != 0` as hard to predict I think, but I would expect (possibly incorrectly) that checks like that are likely quite predictable in practice.

It may be worth trying to improve this gradually to make it easier to catch regressions, e.g. avoid walking the full def-use chain first.



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


More information about the llvm-commits mailing list