Basic code optimisation
moreau francis
francis_moreau2000@yahoo.fr
Wed Mar 2 13:01:00 GMT 2005
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
More information about the Gcc-help
mailing list