[Bug optimization/12395] Suboptimal code with global variables
segher at d12relay01 dot megacenter dot de dot ibm dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 29 15:29:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12395
------- Additional Comments From segher at d12relay01 dot megacenter dot de dot ibm dot com 2003-09-29 14:39 -------
Subject: Re: New: Suboptimal code with global variables
> void foo() {
> extern int a;
> if(++a) ++a;
> }
> This is subobtimal. The optimal code should be:
>
> foo:
> addl $1,a
> je .L1
> addl $1,a
> .L1:
> ret
[I haven't written x86 assembler for a long time, but...]
That code isn't optimal either; something like
foo:
addl $1,a
sbbl $-1,a
ret
would be even better :-)
More information about the Gcc-bugs
mailing list