Does C++ compiler take different decisions regarding inlining two different calls for the same inline function ?
consider a code like this:
inline func(int x) {
return x + (x << 1) + (x << 2) + (x << 3) + (x << 4);
}
int main() {
int y = func(1) + func(2) + func(3) + func(4);
for(int i = 0; i < 100000000; ++i)
y += func(i % 10);
cout << y << endl;
return 0;
}
would the compiler do the same action with the calls before the loop and the one inside the loop ? if we considered code length along with speed optimization then the calls before the loop shouldn't be inlined and the one inside should.