I decided to test the effect of compiler optimization options in practice. There are two files (code2.cpp code3.cpp) with the same code.
#include <iostream> void printer(const int i){ std::cout << i << std::endl; } int main(){ for(int i = 0; i < 100; ++i) printer(i); return 0; } I want to see the assembly code in two different cases. The first case is the use of a compiler with such options g ++ -S -O2 code2.cpp. And the second case is g ++ -S -O3 code3.cpp. As a result, I expected that the file that will be obtained from the use of the -O3 option will be more, because there will be a scan of the cycle.
The results were as follows (the file with the name 2 is what came out of code2.cpp, 3 of * 3.cpp)
26/05/2018 10:37 169 code2.cpp 26/05/2018 11:30 3,865 code2.s 26/05/2018 10:34 169 code3.cpp 26/05/2018 11:30 3,865 code3.s 4 файлов 8,068 байт 2 папок 158,534,213,632 байт свободно Those. the cycle did not turn around, but I really wanted to) What did I do wrong?
-oparameter sets the name of the output file (which is why files 2 and 3 turned out). And you didn’t use optimization at all, it is turned on with the-Okey (capital O) - Mike