This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Need help getting this simple code frag to optimize well. Aliasing problem?
- From: Kevin Lawton <kevinlawton2001 at yahoo dot com>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 28 Sep 2002 22:08:57 -0700 (PDT)
- Subject: Need help getting this simple code frag to optimize well. Aliasing problem?
With gcc 2.95 and 3.0, neither can optimize this simple
code very well. Each emits code to effectively do the
if () check and increment twice. Only thing I can think
of, is that I need to tell the compiler that the external
function call does not touch the local values on the stack.
I can't figure out how to do that. Any input greatly
appreciated.
-Kevin
===== sample.cc ===============================
extern void doSomething(void);
unsigned
someInstruction(unsigned modRM)
{
unsigned a = 0;
const unsigned cond = (modRM==1);
if ( cond )
a++;
doSomething();
if ( cond )
a++;
return a;
}
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com