0

I made a simple quick sort algorithm using C language, named test.c I'm trying to maximize the optimization, so I use -O3 options like belows.

gcc -S -O3 -o test.s test.c
gcc -S -O3 -o test1.s test.s
gcc -S -O3 -o test2.s test1.s
gcc -S -O3 -o test3.s test2.s
.
.
.

But strange thing happens. The more times I did above procedure, the more number of line assembly get.

I don't know why this happens, because I think that I have to get more optimized assembly file that has smaller number of line as I did above procedure.

If this is not right way, using -O3 only one time is the way of the best optimization?

Thanks

1
  • Which version of GCC? My GCC 4.9.2 will not create a new assembly file at all when the source is already in assembly... Commented May 30, 2015 at 21:13

1 Answer 1

1

Most of the gcc optimizations operate on the representation of C source code in an intermediate language. I'm not aware of any optimization specifically operating at the assembler instruction level other than peephole. But that would also be included in -O3.

So yes, -O3 is supposed to be used only once, when turning C source into object files.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.