Hi! On Thu, Dec 01, 2016 at 07:31:18PM -0700, Martin Sebor wrote: > +static bool > +adjust_range_for_overflow (tree dirtype, tree *argmin, tree *argmax) > +{ > + if (TYPE_UNSIGNED (dirtype)) > + { > + *argmin = dirmin; > + *argmax = dirmax; > + } > + else > + { > + *argmin = integer_zero_node; > + *argmax = dirmin; > + }
I still don't really like this mixing of ranges of values and picking of values which result in shortest and longest representation, it is confusing and will be a maintainance nightmare. IMHO much cleaner is first figure out the range the argument (in argtype) has. I.e. look at VR_RANGE and if it is missing, perhaps find out another argtype and in any case, use TYPE_{MIN,MAX}_VALUE (argtype) as the range. I think that should probably be the range presented to the user in diagnostics (i.e. res.arg{min,max}). Next step is to adjust this range for the case where dirtype is different from argtype. This should be done regardless of what way you get the first range from (whether from VR_RANGE or VR_VARYING etc.). The result of this still should be a range of values in dirtype. And the last step should be to pick the values from that range which has shortest and longest representation. For unsigned dirtype that are the bounds of the range from earlier step, for signed dirtype something different (if both bounds are >= 0, then also just those bounds, if both bounds are < 0, then the bounds swapped, otherwise 0 as minimum, then e.g. try both bounds what has longer representation, or take some short path e.g. if abs of the negative bound is >= the positive bound, then use the negative bound as longest, otherwise try both). Jakub