Mikhail Kalashnikov
Mikhail Kalashnikov

Reputation: 1186

Difference between GCC and Clang optimization options

Precondition: I invoke gcc with -O2 optimization flag and clang with -O2 optimization flag.
Does it means the options list passed to the compilers will be the same?
Do clang understand standard GCC options like -funroll-loops?

I did not find anything useful about this question in manual:
http://llvm.org/releases/3.3/tools/clang/docs/UsersManual.html
I can not even find a list of possible GCC compatible options that can be used with clang.

Do clang even do anything with GCC options (or it just ignore them?)
I just need some clarifications on how it work.

Upvotes: 2

Views: 7969

Answers (1)

Oak
Oak

Reputation: 26898

Although in general Clang attempts to copy the command-line options from GCC, there are different optimization passes in GCC and LLVM, so specific optimization flags are not shared. In particular, it means that -O2 does not behave the same in the two compilers.

If you want to see the list of optimizations that GCC applies under -O2, check its documentation; if you want to see the list Clang applies, check this related Stackoverflow question about how to see the list.

Upvotes: 5

Related Questions