# GCC compiler for C and other languages [closed]

I have gone through many reference documents about how a GCC compiler optimizes program. But I am not sure how actually a programmer request GCC attempt to optimize a program. Plz help answering this question and also if any reference links would be helpful. Thanks!!

-
Belongs to the main stackexchange site. – Yuval Filmus Feb 11 at 4:17
Check the GCC documentation, it describes the options in excruciating detail. Or just use -O2, except for very specific cases, this should give good enough code. – vonbrand Feb 11 at 4:34

## closed as off topic by Yuval Filmus, vonbrand, Nicholas Mancuso, Peter Shor, Sasho NikolovFeb 11 at 5:15

Questions on Computer Science Stack Exchange are expected to relate to computer science within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Use the flags -Oxxx. There are lots of different flags, and a few "preset levels" -O0 to -O3. Level 0 means no optimization. Level 3 is full optimization, and could cause bugs (that actually happened to me quite a few times). I usually use level 2.