inlining

bearophile bearophileHUGS at lycos.com
Thu Jul 17 14:33:54 PDT 2008


dsimcha:
> In this case the compiler, not understanding the high-level meaning of what is
> being done, would likely not realize that foo is almost always >= 5 in real-world
> scenarios.

GCC has profile-guided optimization, that is often enough for the compiler to know what branch is the most frequent. In GCC there's the __builtin_expect() too for a similar purpose (if a branch calls a function rarely, the compiler understands it's probably not positive to inline it).

Bye,
bearophile



More information about the Digitalmars-d mailing list