Tell me more ×
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It's 100% free, no registration required.

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!!

share|improve this question
4  
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 Nikolov Feb 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.

1 Answer

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.