Messages in this thread | | | Subject | Re: Linux 2.0.3x & gcc 2.8 [better use egcs for now] | From | Andi Kleen <> | Date | 07 Feb 1998 09:26:44 +0100 |
| |
wmglo@dent.med.uni-muenchen.de (Wolfram Gloger) writes:
> I just checked this code: > > int f(long e) > { > *(&e) = e & 0x1234; > return 0; > } > > and found that egcs-1.0.1 _never_ optimizes the assignment away (no > volatile is needed). So, people should maybe use that rather than > gcc-2.8.0 for compiling 2.0.x.
That is because egcs 1.0.1 doesn't contain the addressof optimization. Post 1.0.1-release versions of egcs have merged that code from 2.8.0.
> > > Kenner admited that it was a bug in the new addressof optimization (which > > finally supports *(&x) = y) and promised a fix for 2.8.1. > > IMHO, a single assignment to *(&x) can _never_ be optimized away > (multiple such assignments could be folded into one possibly). I > can't see why a volatile specification or cast should make a > difference either, since the variable isn't written to by another > context of execution.
It can be optimized away when x is dead and there are no aliases - and it is certainly dead when it is the last operation on a local variable or an argument.
For threads you need to use volatile variables.
-Andi
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |