[Bug tree-optimization/16856] Missed optimisation opportunity with -O2
steven at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun May 22 15:44:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16856
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |steven at gcc dot gnu.org
Resolution| |FIXED
--- Comment #2 from Steven Bosscher <steven at gcc dot gnu.org> 2011-05-22 15:24:48 UTC ---
$ cat t.c
static int bar;
static long baz;
int foo (_Bool x)
{
int y;
if (x) {
++baz;
y = bar;
}
else {
y = bar;
++baz;
}
return y;
}
$ ./cc1 -quiet -m32 -O2 t.c -fdump-tree-optimized
$ cat t.c.143t.optimized
;; Function foo (foo)
foo (_Bool x)
{
long int baz.1;
long int baz.0;
<bb 2>:
if (x_2(D) != 0)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
baz.0_3 = baz;
baz.1_4 = baz.0_3 + 1;
baz = baz.1_4;
goto <bb 5>;
<bb 4>:
baz.0_7 = baz;
baz.1_8 = baz.0_7 + 1;
baz = baz.1_8;
<bb 5>:
return 0;
}
$ cat t.s
.file "t.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
addl $1, baz
xorl %eax, %eax
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.local baz
.comm baz,4,4
.ident "GCC: (GNU) 4.6.0 20110312 (experimental) [trunk revision
170907]"
.section .note.GNU-stack,"",@progbits
More information about the Gcc-bugs
mailing list