------- Comment #4 from j at uriah dot heep dot sax dot de 2007-11-23 10:57 ------- Is the missed optimization in the following code the same?
volatile unsigned char *reg_a = (unsigned char *)42; volatile unsigned char *reg_b = (unsigned char *)34; extern void a(void); extern void b(void); extern void c(void); void decide(void) { signed char diff; diff = *reg_a - *reg_b; if (diff < 0) a(); else if (diff == 0) b(); else if (diff > 0) c(); } The third "if" statement is partially executed: it apparently remembered that diff could not be less than 0, but it still tests against 0 even though that test has just been done before. Verified on both, the AVR and i386 target. Interestingly, by just reordering the code, the third condition will be eliminated by GCC 4.x (but not by GCC 3.x): volatile unsigned char *reg_a = (unsigned char *)42; volatile unsigned char *reg_b = (unsigned char *)34; extern void a(void); extern void b(void); extern void c(void); void decide(void) { signed char diff; diff = *reg_a - *reg_b; if (diff < 0) a(); else if (diff > 0) c(); else if (diff == 0) b(); } If someone thinks that's an entirely different thing than the subject of this bug, please tell me so, and I'll submit a separate one. -- j at uriah dot heep dot sax dot de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |j at uriah dot heep dot sax | |dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33315