This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bad dead code detection ?
- From: Joe Buck <jbuck at synopsys dot com>
- To: David Jobet <david dot jobet at free dot fr>
- Cc: Robert Dewar <dewar at gnat dot com>, tm_gccmail at mail dot kloo dot net, drow at mvista dot com, gcc at gcc dot gnu dot org, rth at redhat dot com
- Date: Thu, 26 Jun 2003 15:56:17 -0700
- Subject: Re: bad dead code detection ?
- References: <20030626211348.B9123F2B55@nile.gnat.com> <200306270042.34279.david.jobet@free.fr>
On Fri, Jun 27, 2003 at 12:42:34AM +0200, David Jobet wrote:
> Well, in fact no.
> The original discussion was wether or not referencing a label by address
> should infer or not on dead code detection ...
>
> For example, in this code :
>
> void f()
> {
> int a;
>
> &a; // taking 'a' by address make 'a' somehow volatile
> }
No, taking a's address and not using the address does not have such an
effect. If it did, we would instantly suffer a 3x speed penalty on the
Stepanov benchmark. If the address is unused except for contexts where it
is canceled out, as in *&a, it is as if the address is never taken, so
a can go in a register.
> I was wondering if it should not be the same as taking a label by address,
> like in :
> void f()
> {
> &&label;
>
> return;
>
> label: // should be dead code, but as I'm taking address of label, I may jump
> somehow to it, so is it dead code anymore ?
> }
Since your premise is wrong, it doesn't support your conclusion.
The compiler is free to throw away any unobservable effect.