From: "John (Eljay) Love-Jensen"
Subject: Re: How can I find out which optimizing techniques were used for each function?
To: Byoungyoung Lee, GCC-help
Date: Tue, 1 Dec 2009 04:51:11 -0800
Hi Byoungyoung Lee,
> Is there anyway in gcc to log the information about which compiler
> options were actually used to optimize each function?
> For example, if I compile a program with option -O3, how could I
> figure out which specific options (such as -funroll-loops or something
> like that) were used to optimize function X ?
I use this technique:
echo '' | gcc -O3 -fverbose-asm -S -xc - -o O3.s
cat O3.s
In the created O3.s assembly source comment, it mentions which flags were
enabled by the -O3 switch.
If you want a detailed assembly line-by-line diagnostic of which particular
optimization was used for a given algorithm, you'll have to do some more
sleuthing.
Such as using -fno-<flag> to disable all the flags, and enable them
one-by-one.
Or perhaps by dumping the compiler state after each optimization pass (which
I think is usually only used as a diagnostic aid for making changes to GCC
itself).
Also, the majority of optimizations do not have a toggle-able flag to
enable/disable them. As I understand it... -O1 enables a whole lot of
optimizations that do not have toggle-able flags. -O2 enables a few more.
-O3 enables one-or-two more.
HTH,
--Eljay
terça-feira, 1 de dezembro de 2009
Opções utilizadas nos diferentes níveis de otimização do GCC
Hoje surgiu uma dica interessante na lista de discussão do GCC. Está reproduzida abaixo:
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário