------- Comment #42 from baldrick at free dot fr 2007-03-02 09:16 ------- Subject: Re: VRP fails to eliminate range checks in Ada code
> Thaks for the detective work! I sort of expected the fold patch to be weird > or > have no effect - but it was needed only (for the testcase) to get rid of the > target_first == 128 comparison, as that is confusing VRP. Basically after > this > comparison we conclude target_first != 128 and drop the earlier target_first > != > 10 > assertion which is the one we can use to optimize the later comparisons. > > So the other solution is to simply not record out-of-bounds assertions. I think fold needs to be fixed, whether or not your fold patch goes in. After all, fold is clearly willing to do create objects like X^Y which take values outside of the range of the type. Once such objects are floating around, any serious use of TYPE_MAX_VALUE or TYPE_MIN_VALUE (when they are non-trivial) will almost certainly give wrong results, as shown by your fold patch. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30911