[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: About processor optimisation with gcc



Hi,

You can make use of the following GCC options for
optimization on various architectures.

For CPU i686 or PentiumPro, Pentium II, Pentium III
---------------------------------------------------
family:
-------

CFLAGS='-O9 -funroll-loops -ffast-math -malign-double
-mcpu=pentiumpro -march=pentiumpro
-fomit-frame-pointer -fno-exceptions'

For CPU i586 or Pentium Processor family:
----------------------------------------

CFLAGS='-O3 -march=pentium -mcpu=pentium -ffast-math
-funroll-loops -fomit-frame-pointer -fforce-mem
-fforce-addr -malign-double -fno-exceptions'

For CPU i486 Processor family:
------------------------------

CFLAGS='-O3 -funroll-all-loops -malign-double
-mcpu=i486 -march=i486 -fomit-frame-pointer
-fno-exceptions'

Below is the explanation of the different optimization
options we used:

* The "-funroll-loops"

The "-funroll-loops" optimization option will perform
the optimization of loop unrolling and will do it only
for loops whose number of iterations can be determined
at compile time or run time.

* The "-funroll-all-loops"

The "-funroll-all-loops" optimization option will also
perform the optimization of loop unrolling and is done
for all loops.

* The "-ffast-math"

The "-ffast-math" optimization option will allow the
GCC compiler, in the interest of optimizing code for
speed, to violate some ANSI or IEEE
rules/specifications.

* The "-malign-double"

The "-malign-double" optimization option will control
whether the GCC compiler aligns double, long double,
and long long variables on a two-word boundary or a
one-word boundary. This will produce code that runs
somewhat faster on a `Pentium' at the expense of more
memory.

* The "-mcpu=cpu_type"

The "-mcpu=cpu_type" optimization option will set the
default CPU to use for the machine type when
scheduling instructions.

° The "-march=cpu_type"

The "-march=cpu_type" optimization option will
generate instructions for the machine and cpu type.
Specifying the "-march=cpu_type" option implies also
to specify the "-mcpu=cpu_type" option in your
compilation.

* The "-fforce-mem"

The "-fforce-mem" optimization option will produce
better code by forcing memory operands to be copied
into registers before doing arithmetic on them and by
making all memory references potential common
subexpressions.

* The "-fforce-addr"

The "-fforce-addr" optimization option will produce
better code by forcing memory address constants to be
copied into registers before doing arithmetic on them.

* The "-fomit-frame-pointer"

The "-fomit-frame-pointer" optimization option, one of
the most interesting, will allow the program to not
keep the frame pointer in a register for functions
that don't need one. This avoids the instructions to
save, set up and restores frame pointers; it also
makes an extra register available in many functions
and makes debugging impossible on most machines.

Note 1: Depending on your processor architecture and
the version of your compiler optimization results may
vary. Benchmark results for the above mentioned
optimization options are available at GCC home page at

            http://egcs.cygnus.com/

Note 2: Most of the above stuff were extracted from
Grehard Mourani's book "Securing and Optimizing
Linux".


Regards,
Arun



__________________________________________________
Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!
http://calendar.yahoo.com/