This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Basic code optimisation
- From: moreau francis <francis_moreau2000 at yahoo dot fr>
- To: gcc-help at gcc dot gnu dot org
- Cc: francis_moreau2000 at yahoo dot fr
- Date: Wed, 2 Mar 2005 14:01:26 +0100 (CET)
- Subject: Basic code optimisation
Hi,
I need your help because I can't make GCC (3.4.2 with
-O2 option) optimize a simple case.
Here it is:
"""
static const struct my_struct {
const int a;
const int b;
} foo = { .a = 2, .b = 3};
int main(int argc, char **argv)
{
int volatile tmp;
tmp = foo.a * foo.b;
return 0;
}
"""
As you notice every things are constants, so GCC
need not to generate a "imult opcode".
Equivalent code should look like:
"""
....
int main(int argc, char **argv)
{
volatile int tmp;
tmp = 6;
return 0;
}
"""
How can I make gcc generate the correct code ?
Thanks for suggestions,
Francis.
Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour dialoguer instantanément avec vos amis. A télécharger gratuitement sur http://fr.messenger.yahoo.com