This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/12395] Suboptimal code with global variables
- From: "segher at d12relay01 dot megacenter dot de dot ibm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Sep 2003 14:39:11 -0000
- Subject: [Bug optimization/12395] Suboptimal code with global variables
- References: <20030924231750.12395.steven@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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 :-)