Reputation: 71
I'm currently implementing a project in C in order to find shortest path between two nodes in a directed graph. I recently tried to use the -O3 optimization flag in compilation and I realized that it made the program much faster.
Does that necessarily mean that the program has imperfections and generally a lot more room for code optimizations? Or does -O3 just make it more optimized no matter how good my code is?
Upvotes: 1
Views: 4658
Reputation: 2177
In general, C optimization does things that you have no control over. The changes that the optimizer makes are mostly to the assembly and machine code that is generated by the compiler.
That being said, there are certain inefficiencies that could be included in your code that the optimizer fixes, and there's no way for anyone to know without looking at the code.
For a full list of all the things the -O3
optimization does, you can read the GNU's specification for the flag here.
Upvotes: 4