On Monday, 24 February 2014 at 02:05:31 UTC, Walter Bright wrote:
1. It provides information to the compiler about runtime frequency that it cannot obtain otherwise. This is very useful information for generating better code.
This answers to your own previous question: this is what makes "inline" a special optimization.

3. In the end, the compiler should make the decision. Inlining does not always result in faster code, as I pointed out in another post.
Honestrly, in the small profiling I've done in my life, at least inlining never made my code slower. But I do realize this is not relevant to the discussion.

Perhaps the lesson is the word 'inline' carries certain expectations with it, and the feature would be better positioned as something like:

    pragma(usage, often);
    pragma(usage, rare);
Yes, I think "inline" carries huge expectations: the expectation for the compiler to comply. If the plan is hinting frequency information, then "usage" makes way more sense. It might be used in if blocks and in switch cases too, when branch prediction might be sloppy or unoptimal.

Reply via email to