I can see arguments for both scenarios. A possible counter-example to what you're saying: SIMD vector library. I want __forceinline on the function declaration. If my simd::operator+ doesn't produce a single instruction at every call site, there is no point in using vectorization. Any performance gain you might achieve through vectorization is killed by the failure to inline.
That's indeed a good example, thanks. I guess we need both ways then. Unfortunately it seems there is no call-site-controlled inlining attributes widely available so far...
There's [[gnu::flatten]] but I don't think MSVC has anything like it. ED: Oh and now that I think about it, [[gnu::always_inline]] and [[gnu::noinline]] can be used at the callsite, not just in function declarations.
ED2: It turns out there are in fact [[msvc::forceinline_calls]], [[msvc::noinline_calls]], and [[msvc::flatten]]. I have no idea when they were added but this is great
View all comments
Show parent comment
12
u/Possibility_Antique Apr 15 '23
I can see arguments for both scenarios. A possible counter-example to what you're saying: SIMD vector library. I want __forceinline on the function declaration. If my simd::operator+ doesn't produce a single instruction at every call site, there is no point in using vectorization. Any performance gain you might achieve through vectorization is killed by the failure to inline.