Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Inline Expansion

This topic is 6415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there I wonder how inline expansion works exactly. I''ve an inline function that calls another inline function. Does the compiler the full expansion on both? Can one set the level of inline expansion? (e.g. Max 8 expansions). In BCB5, I haven''t found such configuration... I don''t know asm, so I can''t check my sourcecode, whether the expansion works or not. (Of course I could benchmark). thanx for your replies.

Share this post

Link to post
Share on other sites
If the both functions are functions that the compiler would inline, then it will inline both and optimize on the inlined code.

For example if I have:

inline int FuncA(int a) { return a; }
inline int FuncB(int b) { return FuncA(-b * b); }
inline int FuncC(int c) { return FuncB(c + c); }
inline int FuncD(int d) { return FuncC(- d); }

and call

int a = FuncD(4);

the compiler will expand through all four function calls (and then replace the whole thing with a -64).

As far as I know you can''t affect how nested the functions will be. And probably shouldn''t, as you might emit code for a function that is expanded elsewhere.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!