bad dead code detection ?

Joe Buck jbuck@synopsys.com
Fri Jun 27 00:12:00 GMT 2003


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.





More information about the Gcc mailing list