This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]