This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: VRP: abstract out wide int CONVERT_EXPR_P code

On 27 August 2018 14:24:33 CEST, Aldy Hernandez <> wrote:
>Phew, I think this is the last abstraction.  This handles the unary 

+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?


+      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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]