I have the following simple function:
This function is called frequently in my program (millions of times every minute). I noticed while doing some optimisations today that Visual Studio is not actually inlining the function. No real surprises here since VS ignores most inline recommendations and does what it wants.Code:inline int Gain(int in, int mq) { return (in * mq) >> 9; }
The issue I have is that making this function inline makes a huge difference - I get approx a 50% performance gain if I just substitute my calls to Gain() with this code directly.
I have tried using __forceinline. No help - VS seems to ignore this too.
I have tried switching on "Maximize Speed" (/O2). No difference.
I have tried switching on "Favor Fast Code" (/Ot). Executable increased in size by 10% and got slower by about 15%. Obviously that's no good.
Can anyone shed some light on why the compiler refuses to inline this function?
BJW




Reply With Quote