------- Comment #37 from baldrick at free dot fr 2007-02-28 23:30 ------- Subject: Re: VRP fails to eliminate range checks in Ada code
> With bootstrapping the compiler and then checking you get > > FAIL: c35507j > FAIL: cd92001 > FAIL: cxh1001 I get a slightly different set (i486-linux-gnu): c35505f c35507j c35508g cxh1001 The intersection is c35507j cxh1001. I worked on c35507j a bit. Fold did it! The problem is that the value of arg1, a constant, is not in the range of its own type! It was fold itself that created the (wrong) constant, in this case of constant of value 0 for a type with range 4..5 . Fold needs to be consistent. Either it decides that it is OK, for computational purposes, to violate range restrictions - but in that case it can't then simplify comparisons based on values being outside the range of the type, which is what this patch does - or it always respects range restrictions, which is not currently the case and will take quite some work to ensure (adding some assertions in the various routines that construct constants would be helpful). In fact, when you think about it this transformation is quite dubious, at least if both arguments have the same type. If that case, if arg1 is outside the range of arg0's type, then it is outside the range of its own type! i.e. it is a bogus constant and a sign of a compiler bug rather than of a useful simplification! -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30911