This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
label reference missed
- From: Ulrich Drepper <drepper at redhat dot com>
- To: gcc-bugs <gcc-bugs at gcc dot gnu dot org>
- Date: Thu, 22 Aug 2002 20:38:36 -0700
- Subject: label reference missed
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I have this little piece of code:
int
foo (int a)
{
asm volatile ("jmp %0"::"m" (*&&fff));
if (1)
{
puts ("if");
}
else
{
fff:
puts ("else");
}
return 0;
}
It compiles fine but gcc doesn't realize that the label fff is
referenced. The result is that the entire 'else' branch is gone. Note
that this construct works fine if the condition of the 'if' is changed
from '1' to 'a'. But this defeats the purpose (in part).
The possibilities opened by code like that above are quite big. On x86,
for instance, we often have sequences like this (after macro expansion)
in lowlevel code:
if (({ unsigned char r;
asm ("cmpxchgl %3, %0; sete %1"
: "=m" (mem), "=q" (r)
: "0" (mem), "r" (oldval));
r; }) != 0)
...
which expands to something like
cmpxchgl ...,...
sete ...
testl ..., ...
jne ...
With a construct like that above this could be reduced to
cmpxchgl ...,...
je ...
I imagine that the change necessary to achieve this is minimal. It
would only require to recognize label references and mark the basic
blocks they introduce as alive.
I'll file a bug in gnats if it is agreed on that this is useful and
feasable.
- --
- ---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9Za5B2ijCOnn/RHQRAgZ3AJ90bS9M7QhMCABiWVOdSkgF+I6O+gCglJ5s
PnPQ+/qp4LNqrjsZWlciX6Q=
=R8UD
-----END PGP SIGNATURE-----