I'm interested in knowing how GCC differs from Intel's ICC in terms of the optimization levels and catering to specific processor architecture. I'm using GCC 4.1.2 20070626 and ICC v11.1 for Linux.
How does ICC's optimization levels (O1 to O3) differ from GCC, if they differ at all?
The ICC is able to cater specifically to different architectures (IA-32, intel64 and IA-64). I've read that GCC has the -march
compiler option which I think is similar, but I can't find a list of the options to use. I'm using Intel Xeon X5570, which is 64-bit. Are there any other GCC compiler options I could use that would cater my applications for 64-bit Intel CPUs?
icc -O2 -unroll2
is roughly equivalent to gcc -O3 -ffast-math -fno-cx-limited-range -funroll-loops --param max-unroll-times=2
gcc -O1 doesn't enable SIMD auto-vectorization for either compiler, so there is less difference.
ICC with no options defaults to optimization enabled and -fp-model=fast=1
(a bit less aggressive than gcc -ffast-math
), but GCC defaults to -O0
. (Also -fno-fast-math
even with gcc -O3
. Only gcc -Ofast
enables fast-math like the ICC default.)
-march=native
is the GCC option to use the full instruction set of the build machine. ICC supports -march=native
as equivalent to its own -xHost
option. At the time of this question, that ICC option may have worked only for Intel CPUs.
GCC can be configured with either -m64
or -m32
as the default, but the same compiler can compile binaries of either bitness. ICC provides separately built compilers to target 64-bit or 32-bit mode; icc expects you to choose, if both are installed, by sourcing their path setting script.
See section 3.17.15 in the GCC manual, ie386 and x86-64 Options for the full list and description of all the options applicable to those architectures (IA-64 is Itanium, and it's unlikely you have one of those).
The most important options in this context are:
-m64
Generate 64-bit code;-march=
Generate instructions for a specific CPU type; and-mtune=
Tune the code for a specific CPU type.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With