This is the mail archive of the gcc@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] |
On Friday 22 December 2006 00:58, Denis Vlasenko wrote:On Tuesday 19 December 2006 23:39, Denis Vlasenko wrote:There are a lot of 100.00% safe optimizations which gcc can do. Value range propagation for bitwise operations, for oneOr this, absolutely typical C code. i386 arch can compare 16 bits at a time here (luckily, no alighment worries on this arch):
int f(char *p) { if (p[0] == 1 && p[1] == 2) return 1; return 0; }
Definitely not 100% safe. p may point to memory that is sensitive to the access width and/or number of accesses. (ie. memory mapped IO).
A program that depends on this is plain wrong. There is no guarantee that memory references are as they appear in the program. For a non-volatile variable, any such optimization is valid. For instance if the flow can be used to prove that p[0] is already 1, then there is no need to repeat the read.
Paul
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |