On Fri, Jun 29, 2018 at 7:55 PM Aldy Hernandez <al...@redhat.com> wrote: > > Howdy! > > Attached are some cleanups to the VRP code dealing with PLUS/MINUS_EXPR > on ranges. This will make it easier to share code with any other range > implementation in the future, but is completely independent from any > other work. > > Currently there is a lot of code duplication in the PLUS/MINUS_EXPR > code, which we can easily abstract out and make everything easier to > read. I have tried to keep functionality changes to a minimum to help > in reviewing. > > A few minor things that are different: > > 1. As mentioned in a previous thread with Richard > (https://gcc.gnu.org/ml/gcc/2018-06/msg00100.html), I would like to use > the first variant here, as they seem to ultimately do the same thing: > > - /* Get the lower and upper bounds of the type. */ > - if (TYPE_OVERFLOW_WRAPS (expr_type)) > - { > - type_min = wi::min_value (prec, sgn); > - type_max = wi::max_value (prec, sgn); > - } > - else > - { > - type_min = wi::to_wide (vrp_val_min (expr_type)); > - type_max = wi::to_wide (vrp_val_max (expr_type)); > - } > > 2. I've removed the code below, as it seems to be a remnant from when > the comparisons were being done with double_int's. The overflow checks > were/are being done prior anyhow. For that matter, I put in some > gcc_unreachables in the code below, and never triggered it in a > bootstrap + regtest. > > - /* Check for type overflow. */ > - if (min_ovf == 0) > - { > - if (wi::cmp (wmin, type_min, sgn) == -1) > - min_ovf = -1; > - else if (wi::cmp (wmin, type_max, sgn) == 1) > - min_ovf = 1; > - } > - if (max_ovf == 0) > - { > - if (wi::cmp (wmax, type_min, sgn) == -1) > - max_ovf = -1; > - else if (wi::cmp (wmax, type_max, sgn) == 1) > - max_ovf = 1; > - } > > Everything else is exactly as it was, just abstracted and moved around. > > To test this, I compared the results of every binary op before and after > this patch, to make sure that we were getting the same exact ranges. > There were no differences in a bootstrap plus regtest. > > OK for trunk?
OK. Thanks, Richard.