------- Comment #32 from baldrick at free dot fr 2007-03-09 11:34 ------- Subject: Re: [4.3 regression] ACATS cxh1001 fails
> Well, the only problem with V_C_E is that if you assert on the range of the > base type like > > if (V_C_E <X'Base> (y) > 5) > abort(); > > that you still want VRP to infer that V_C_E <X'Base> (y) is <= 5 after this > check (to eliminate further checks). I don't think this is a very serious problem. My understanding is that the checks can be divided into two classes: normal checks and validity checks. A normal check, such as when you do a type conversion, does not use a V_C_E, it just does: if (y < new_type_lb || y > new_type_ub) abort; new_var = (new_type) y; A validity check does: if (V_C_E <X'Base> (y) < x_lb || V_C_E <X'Base> (y) > x_ub) abort(); Note how it checks that x is in the range of x's type, so this does not give any new information about x. It is true that multiple validity checks will not be eliminated (multiple normal checks will be eliminated), but validity checks are not that common. One place that might hurt is in array accesses: IIRC the front-end does a validity check on the index before accessing an array, rather than a normal check, because it considers it too dangerous to do otherwise (eg: they want to catch the case when the index has an out-of-range value because it is uninitialized). My suggested use of a builtin would allow multiple redundant validity checks to be safely eliminated, because the builtin would be a "pure" function. The validity check becomes: y2 = __builtin_nop(y); if (y2 < x_lb || y2 > x_ub) abort(); Now suppose you do another one: y22 = __builtin_nop(y); if (y22 < x_lb || y22 > x_ub) abort(); The compiler can deduce that y2 and y22 are the same, and eliminate the second check. > I believe this will not automatically > happen at the moment because V_C_E <X'Base> (y) will not have the same > ssa name assigned for evey occurance. But of course we will never know until > the Ada FE people finally fix their frontend. > > All the mess would be way easier if the FE would not expose the subtypes to > the middle-end... I agree. The LLVM model seems more sensible in this regard. D. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26797