[llvm] [InstCombine] Set !prof metadata on Selects identified by add.ll test (PR #158743)
Alan Zhao via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 17 15:50:01 PDT 2025
alanzhao1 wrote:
> > > That also sounds reasonable to me. I assume checking for a non-zero function entry count is not particularly expensive?
> >
> >
> > It's fetching a function metadata, and should't be expensive. We can also cache this over the whole pass rather than checking more locally.
>
> A cache is probably not needed, so let's start without it.
>
> It would be nice to have a helper for this though, I'd expect this to be a rather common pattern for InstCombine in particular, so if we could just replace `SelectInst::Create()` with `createSelectWithUnknownBranchWeights()` that would be nice.
Done. I created the function `setExplicitlyUnknownBranchWeightsIfProfiled(...)` which takes an instruction and adds unknown branch weights if the enclosing function has a nonzero entry count.
https://github.com/llvm/llvm-project/pull/158743
More information about the llvm-commits
mailing list