On 27 August 2018 14:24:33 CEST, Aldy Hernandez <al...@redhat.com> wrote:
>Howdy!
>
>Phew, I think this is the last abstraction.  This handles the unary 
>CONVERT_EXPR_P code.

+bool
+wide_int_range_convert_tree (tree &tmin, tree &tmax,
+                            tree outer_type,
+                            signop inner_sign,
+                            unsigned inner_prec,
+                            const wide_int &vr0_min,
+                            const wide_int &vr0_max)
+{
+  /* If the conversion is not truncating we can convert the min and
+     max values and canonicalize the resulting range.  Otherwise we
+     can do the conversion if the size of the range is less than what
+     the precision of the target type can represent.  */
+  if (TYPE_PRECISION (outer_type) >= inner_prec
+      || wi::rshift (wi::sub (vr0_max, vr0_min),
+                    wi::uhwi (TYPE_PRECISION (outer_type), inner_prec),
+                    inner_sign) == 0)
+    {
+      signop outer_sign = TYPE_SIGN (outer_type);
+      outer_sign = inner_sign;

AFAIU you don't need outer_sign at all ( since you want inner_sign always ) or 
what subtlety  am I missing?

Thanks,

+      tmin = force_fit_type (outer_type,
+                            widest_int::from (vr0_min, outer_sign), 0, false);
+      tmax = force_fit_type (outer_type,
+                            widest_int::from (vr0_max, outer_sign), 0, false);
+      return (!operand_equal_p (tmin, TYPE_MIN_VALUE (outer_type), 0)
+             || !operand_equal_p (tmax, TYPE_MAX_VALUE (outer_type), 0));
+    }
+  return false;
+}

Reply via email to