[Bug target/12395] Suboptimal code with global variables
steven at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Feb 11 13:14:00 GMT 2006
------- Comment #10 from steven at gcc dot gnu dot org 2006-02-11 13:14 -------
This is, in fact, a rare case where RTL store motion does something useful.
With "-O2 -fomit-frame-pointer -march=pentium4" we produce:
movl a, %eax
addl $1, %eax
movl %eax, a
testl %eax, %eax
je .L4
addl $1, %eax
movl %eax, a
.L4:
ret
but with "-O2 -fomit-frame-pointer -march=pentium4 -fgcse-sm" we get:
foo:
movl a, %eax
addl $1, %eax
je .L5
addl $1, %eax
movl %eax, a
ret
.L5:
movl $0, a
ret
which is much closer to what we want to get to eventually.
Looking at the first snippet, we shouldn't really need GCSE store-motion for
this, because the store to a is not partially redundant. It is fully redundant
and could be sunk if we had a generic hoisting pass that can lift and sink
code. The current implementation of code hoisting in GCSE can only lift code,
not sink it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12395
More information about the Gcc-bugs
mailing list