Suppose I have the following C line:
int a = 4 7;
When compiling this line, GCC will always produce something like mov DWORD PTR [rbp-X], 0xb
, as the result of this computation is constant and known at compile time. Is there a way to disable this behaviour to have a mov 4, add 7 instead?
A quick search led me to the -O0 or -OG flags, but they turn off other kinds of optimizations, such as the fact that functions should be aligned in memory.
CodePudding user response:
Is there a way to disable this behaviour to have a mov 4, add 7 instead?
No. Evaluation of elementary constant expressions is built into the compiler.