How I can setup the compiler to generate identical code? For example:
inline bool iszero(int a)
{
return (a == 0);
}
int main()
{
int a = 4;
if(a == 0) // First
a = 5;
if(iszero(a)) // Second
a = 5;
///...
}
In debug mode (with inlining) disassembled code look like:
if(a == 0) // First
a = 5;
bool temp; // Second
if(a == 0)
temp = 0;
else
temp = 1;
if(temp == 0)
a = 5;
Why that happens?
Why this question has been asked? I need to debug my application with inlining functions (for speed up debug) and I do not want to lose performance in debug mode.
Compile in release mode, with full optimizations. The generated code will be the equivalent of:
There’s no point in comparing code with no optimizations on, as there’s no point in benchmarking with optimizations off.