roughly yes. To be specific, it’s not an issue with @code_typed, but with the typed code. Julia goes through several stages of optimization, and @code_typed is correctly showing that this optimization is not being done by julia (but it is getting done by LLVM). It would be better if Julia was smart enough to prove this because deleting code early in the compilation pipeline tends to speed up compilation (because the rest of compilation then has less code to work with).
It does constant-fold(?). So change/clarify the title?
If I understand @Oscar_Smith correctly, that happens, just late in the compilation pipeline. I.e. we can rely on it, and that it would most likely inline, even without:
julia> @inline isnegative(x) = x < zero(x)
What you mentioned would only speed up compilation, not runtime use of code after that.
The ret i8 0 that @code_llvm doesn’t seem bad enough, but @code_native shows more verbose with e.g. unneeded movq %rsp, %rbp. You would get that in your code if NOT inlined, but otherwise not.
My intended use case was the one suggested above, where isnegative is used in an if-else with different types returned in each branch. I was hoping that this may be evaluated in a type-stable manner. What wording would you recommend for the title?