nikic wrote: > > I suspect we want to do something with llvm.assume, or something like that, > > not use a select. > > No. `assume` is used as "optimization hint".
Not sure if that's what you mean, but violating an assume is immediate undefined behavior. It's not a "hint" in the heuristic sense, it encodes a precondition. Of course, the *purpose* of assumes is to improve optimizations by providing more information, so it is an optimization hint in that sense. > `undef` is used as "semantic undefined load". See > https://llvm.org/docs/UndefinedBehavior.html#undef-values > > > Undef values are deprecated and should be used only when strictly > > necessary. Uses of undef values should be restricted to representing loads > > of uninitialized memory. This is the only part of the IR semantics that > > cannot be replaced with alternatives yet (work in ongoing). This is referring to the result of loading uninitialized memory being undef. What you are doing here is loading from an undef pointer, which is UB. This does encode the precondition as well, but in a way that is likely to get lost in optimization (I have a patch somewhere that removes that select in favor of a freeze, which will break this pattern) and is not understood by LLVM in the way assumes are. Overall, I'm not entirely clear on why using this select form is better than using assume. https://github.com/llvm/llvm-project/pull/159046 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits