On Fri, May 20, 2016 at 11:20 AM, Eric Botcazou <ebotca...@adacore.com> wrote: > Hi, > > this enhances VRP, more precisely compare_values_warnv, so as not to give up > for the NAME + CST1 vs CST2 comparison if type overflow is undefined and the > difference CST2 - CST1 overflows or underflows. This makes it possible to > optimize out a class of overflow checks in Ada, typically: > > function F (Val, Max : Integer) return Integer is > begin > if Val >= Max then > return Max; > end if; > return Val + 1; -- overflow check can never fail > end; > > The patch also streamlines the handling of symbolic values in the function by > calling get_single_symbol instead of doing the decompostion manually twice. > > The Ada part is a tweak to expose more opportunities to VRP by removing casts. > > Tested on x86_64-suse-linux, OK for the mainline?
Ok. Thanks, Richard. > > 2016-05-20 Eric Botcazou <ebotca...@adacore.com> > > * tree-vrp.c (compare_values_warnv): Simplify handling of symbolic > ranges by calling get_single_symbol and tidy up. Look more closely > into NAME + CST1 vs CST2 comparisons if type overflow is undefined. > ada/ > * gcc-interface/decl.c (gnat_to_gnu_entity)<E_Signed_Integer_Subtype> > Make same-sized subtypes of signed base types signed. > * gcc-interface/utils.c (make_type_from_size): Adjust to above > change. > (unchecked_convert): Likewise. > > > 2016-05-20 Eric Botcazou <ebotca...@adacore.com> > > * gnat.dg/opt53.adb: New test. > * gnat.dg/opt54.adb: Likewise. > > -- > Eric Botcazou