[llvm] [SimplfyCFG] Set `MD_prof` for `select` used for certain conditional simplifications (PR #154426)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 4 14:48:40 PDT 2025
nikic wrote:
> > I'm not sure on this one. The thing is that the canonical form here is a plain and/or, and the only reason we use select is to prevent poison-propagation issues. Improvements to frontend information (e.g. if you slap noundef on the relevant arguments) or analysis may end up converting the select to and/or, in which case we won't be able to preserve the prof metadata. Cases where better analysis has adverse effects are always awkward.
> > Do you have an example where duplicating this information on the select ends up being useful? After all, these weights are already on the branch over the select.
>
> The approach is defensive rather than example-driven, because at large scale, places where profile information starts deteriorating are hard to identify, and it's also hard to know there's a problem - hence the approach of "if an instruction can have MD_profile, and it's known, let's capture it, otherwise mark it as `unknown`". This is compounded by changes that break downstream assumptions. In this case, the profile info is easily known, so it seems prudent to capture it rather than marking it unknown.
>
> Not sure what you mean by "better analysis has adverse effects"?
If you add noundef to the parameters for the condition, then we'll generate and/or instead of select, which can't carry !prof metadata.
https://github.com/llvm/llvm-project/pull/154426
More information about the llvm-commits
mailing list