On 2/3/2015 1:11 AM, Mike wrote:
All things being equal, will there be any difference between the resulting
binaries for each of these scenarios?

No.

Another way of putting it:  Does pragma(inline, true) simply allow the user to
compiler parts of their source file with -inline?

Yes.

pragma(inline, false) paradoxically can be used to improve performance. 
Consider:

  if (cond)
    foo();
  else
    bar();

If cond is nearly always false, then foo() is rarely executed. If the compiler inlines it, it will likely take away registers from being used to inline bar(), and bar() needs those registers. By marking foo() as not inlinable, it won't consume those registers. (Also, inlining foo() may consume much code, making for a less efficient jump around it and making it less likely for the hot code to fit in the cache.)

This is why I'm beginning to think a pragma(hot, true/false) might be a better approach, as there are more optimizations that can be done better if the compiler knows which branches are hot or not.

Reply via email to