> > I think that it is easy for back end to make good use of > > TYPE_MIN_VALUE/TYPE_MAX_VALUE. Namely, consider the assignment > > > > x := y + z * w; > > > > where variables y, z and w have values in the interval [0,7] and > > x have values in [0,1000]. Pascal converts the above to the > > following C like code: > > > > int tmp = (int) y + (int) z * (int) w; > > x = (tmp < 0 || tmp > 1000)? (Range_Check_Error (), 0) : tmp; > > > > I expect VRP to deduce that tmp will have values in [0..56] and > > eliminate range check. Also, it should be clear that in the > > assigment above artithmetic can be done using any convenient > > precision. > VRP can certainly do this -- I added the ability to see through > more typecasts a while back. In general, I've tried to improve > the ability of our optimizers to eliminate or at least "see through" > some typecasts. However, that capability is often very limited > and the ability to see through type casts is not pervasive in > the optimization pipeline.
Hi Jeff, on the subject of seeing through typecasts, I was playing around with VRP and noticed that the following "if" statement is not eliminated: int u (unsigned char c) { int i = c; if (i < 0 || i > 255) return -1; /* never taken */ else return 0; } Is it supposed to be? Thanks, Duncan.