Пример #1
0
void store_VRPs()
{
  size_t i;
  unsigned num = num_ssa_names;
  if(VRP_min_array)
    free (VRP_min_array);
  if(VRP_max_array)
    free (VRP_max_array);
  if(p_VRP_min)
    free (p_VRP_min);
  if(p_VRP_max)
    free (p_VRP_max);
  VRP_min_array = XCNEWVEC (tree, num);
  VRP_max_array = XCNEWVEC (tree, num);
  p_VRP_min = XCNEWVEC (bool, num);
  p_VRP_max = XCNEWVEC (bool, num);

  //restrict_range_to_consts();
  
  for (i = 0; i < num; i++)
    if (vr_value[i] && vr_value[i]->type ==  VR_RANGE && 
        TREE_CODE(vr_value[i]->min) == INTEGER_CST && 
        TREE_CODE(vr_value[i]->max) == INTEGER_CST && 
        !TREE_OVERFLOW (vr_value[i]->min) &&
        !TREE_OVERFLOW (vr_value[i]->max))
    {
      p_VRP_min[i] = true;
      p_VRP_max[i] = true;
      VRP_min_array[i] = vr_value[i]->min;
      VRP_max_array[i] = vr_value[i]->max;
    }
    else
    {
      p_VRP_min[i] = false;
      p_VRP_max[i] = false;
    }
  set_num_vr_values(num);
}
Пример #2
0
static tree 
chrec_convert_1 (tree type, tree chrec, tree at_stmt,
		 bool use_overflow_semantics)
{
  tree ct, res;
  tree base, step;
  struct loop *loop;

  if (automatically_generated_chrec_p (chrec))
    return chrec;
  
  ct = chrec_type (chrec);
  if (ct == type)
    return chrec;

  if (!evolution_function_is_affine_p (chrec))
    goto keep_cast;

  loop = current_loops->parray[CHREC_VARIABLE (chrec)];
  base = CHREC_LEFT (chrec);
  step = CHREC_RIGHT (chrec);

  if (convert_affine_scev (loop, type, &base, &step, at_stmt,
			   use_overflow_semantics))
    return build_polynomial_chrec (loop->num, base, step);

  /* If we cannot propagate the cast inside the chrec, just keep the cast.  */
keep_cast:
  res = fold_convert (type, chrec);

  /* Don't propagate overflows.  */
  if (CONSTANT_CLASS_P (res))
    {
      TREE_CONSTANT_OVERFLOW (res) = 0;
      TREE_OVERFLOW (res) = 0;
    }

  /* But reject constants that don't fit in their type after conversion.
     This can happen if TYPE_MIN_VALUE or TYPE_MAX_VALUE are not the
     natural values associated with TYPE_PRECISION and TYPE_UNSIGNED,
     and can cause problems later when computing niters of loops.  Note
     that we don't do the check before converting because we don't want
     to reject conversions of negative chrecs to unsigned types.  */
  if (TREE_CODE (res) == INTEGER_CST
      && TREE_CODE (type) == INTEGER_TYPE
      && !int_fits_type_p (res, type))
    res = chrec_dont_know;

  return res;
}
Пример #3
0
tree 
chrec_convert (tree type, 
	       tree chrec)
{
  tree ct;
  
  if (automatically_generated_chrec_p (chrec))
    return chrec;
  
  ct = chrec_type (chrec);
  if (ct == type)
    return chrec;

  if (TYPE_PRECISION (ct) < TYPE_PRECISION (type))
    return count_ev_in_wider_type (type, chrec);

  switch (TREE_CODE (chrec))
    {
    case POLYNOMIAL_CHREC:
      return build_polynomial_chrec (CHREC_VARIABLE (chrec),
				     chrec_convert (type,
						    CHREC_LEFT (chrec)),
				     chrec_convert (type,
						    CHREC_RIGHT (chrec)));

    default:
      {
	tree res = fold_convert (type, chrec);

	/* Don't propagate overflows.  */
	TREE_OVERFLOW (res) = 0;
	if (CONSTANT_CLASS_P (res))
	  TREE_CONSTANT_OVERFLOW (res) = 0;

	/* But reject constants that don't fit in their type after conversion.
	   This can happen if TYPE_MIN_VALUE or TYPE_MAX_VALUE are not the
	   natural values associated with TYPE_PRECISION and TYPE_UNSIGNED,
	   and can cause problems later when computing niters of loops.  Note
	   that we don't do the check before converting because we don't want
	   to reject conversions of negative chrecs to unsigned types.  */
	if (TREE_CODE (res) == INTEGER_CST
	    && TREE_CODE (type) == INTEGER_TYPE
	    && !int_fits_type_p (res, type))
	  res = chrec_dont_know;

	return res;
      }
    }
}
Пример #4
0
tree
convert (tree type, tree expr)
{
  enum tree_code code = TREE_CODE (type);

  if (!expr)
   return error_mark_node;

  if (type == TREE_TYPE (expr)
      || TREE_CODE (expr) == ERROR_MARK)
    return expr;
  if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK)
    return error_mark_node;
  if (code == VOID_TYPE)
    return build1 (CONVERT_EXPR, type, expr);
  if (code == BOOLEAN_TYPE)
    return fold_convert (type, expr);
  if (code == INTEGER_TYPE)
    {
      if (type == char_type_node || type == promoted_char_type_node)
	return fold_convert (type, expr);
      if ((really_constant_p (expr)
	   || (! flag_unsafe_math_optimizations
	       && ! flag_emit_class_files))
	  && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
	  && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT)
	return convert_ieee_real_to_integer (type, expr);
      else
	{
	  /* fold very helpfully sets the overflow status if a type
	     overflows in a narrowing integer conversion, but Java
	     doesn't care.  */
	  tree tmp = fold (convert_to_integer (type, expr));
	  if (TREE_CODE (tmp) == INTEGER_CST)
	    TREE_OVERFLOW (tmp) = 0;
	  return tmp;
	}
    }	  
  if (code == REAL_TYPE)
    return fold (convert_to_real (type, expr));
  if (code == POINTER_TYPE)
    return fold (convert_to_pointer (type, expr));
  error ("conversion to non-scalar type requested");
  return error_mark_node;
}
Пример #5
0
tree
streamer_read_integer_cst (struct lto_input_block *ib, struct data_in *data_in)
{
  tree result, type;
  HOST_WIDE_INT low, high;
  bool overflow_p;

  type = stream_read_tree (ib, data_in);
  overflow_p = (streamer_read_uchar (ib) != 0);
  low = streamer_read_uhwi (ib);
  high = streamer_read_uhwi (ib);
  result = build_int_cst_wide (type, low, high);

  /* If the original constant had overflown, build a replica of RESULT to
     avoid modifying the shared constant returned by build_int_cst_wide.  */
  if (overflow_p)
    {
      result = copy_node (result);
      TREE_OVERFLOW (result) = 1;
    }

  return result;
}
Пример #6
0
static tree
chrec_convert_1 (tree type, tree chrec, gimple *at_stmt,
		 bool use_overflow_semantics)
{
  tree ct, res;
  tree base, step;
  struct loop *loop;

  if (automatically_generated_chrec_p (chrec))
    return chrec;

  ct = chrec_type (chrec);
  if (useless_type_conversion_p (type, ct))
    return chrec;

  if (!evolution_function_is_affine_p (chrec))
    goto keep_cast;

  loop = get_chrec_loop (chrec);
  base = CHREC_LEFT (chrec);
  step = CHREC_RIGHT (chrec);

  if (convert_affine_scev (loop, type, &base, &step, at_stmt,
			   use_overflow_semantics))
    return build_polynomial_chrec (loop->num, base, step);

  /* If we cannot propagate the cast inside the chrec, just keep the cast.  */
keep_cast:
  /* Fold will not canonicalize (long)(i - 1) to (long)i - 1 because that
     may be more expensive.  We do want to perform this optimization here
     though for canonicalization reasons.  */
  if (use_overflow_semantics
      && (TREE_CODE (chrec) == PLUS_EXPR
	  || TREE_CODE (chrec) == MINUS_EXPR)
      && TREE_CODE (type) == INTEGER_TYPE
      && TREE_CODE (ct) == INTEGER_TYPE
      && TYPE_PRECISION (type) > TYPE_PRECISION (ct)
      && TYPE_OVERFLOW_UNDEFINED (ct))
    res = fold_build2 (TREE_CODE (chrec), type,
		       fold_convert (type, TREE_OPERAND (chrec, 0)),
		       fold_convert (type, TREE_OPERAND (chrec, 1)));
  /* Similar perform the trick that (signed char)((int)x + 2) can be
     narrowed to (signed char)((unsigned char)x + 2).  */
  else if (use_overflow_semantics
	   && TREE_CODE (chrec) == POLYNOMIAL_CHREC
	   && TREE_CODE (ct) == INTEGER_TYPE
	   && TREE_CODE (type) == INTEGER_TYPE
	   && TYPE_OVERFLOW_UNDEFINED (type)
	   && TYPE_PRECISION (type) < TYPE_PRECISION (ct))
    {
      tree utype = unsigned_type_for (type);
      res = build_polynomial_chrec (CHREC_VARIABLE (chrec),
				    fold_convert (utype,
						  CHREC_LEFT (chrec)),
				    fold_convert (utype,
						  CHREC_RIGHT (chrec)));
      res = chrec_convert_1 (type, res, at_stmt, use_overflow_semantics);
    }
  else
    res = fold_convert (type, chrec);

  /* Don't propagate overflows.  */
  if (CONSTANT_CLASS_P (res))
    TREE_OVERFLOW (res) = 0;

  /* But reject constants that don't fit in their type after conversion.
     This can happen if TYPE_MIN_VALUE or TYPE_MAX_VALUE are not the
     natural values associated with TYPE_PRECISION and TYPE_UNSIGNED,
     and can cause problems later when computing niters of loops.  Note
     that we don't do the check before converting because we don't want
     to reject conversions of negative chrecs to unsigned types.  */
  if (TREE_CODE (res) == INTEGER_CST
      && TREE_CODE (type) == INTEGER_TYPE
      && !int_fits_type_p (res, type))
    res = chrec_dont_know;

  return res;
}
Пример #7
0
void
print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
{
    enum tree_code_class tclass;

    if (node == 0)
        return;

    tclass = TREE_CODE_CLASS (TREE_CODE (node));

    /* Always print the slot this node is in, and its code, address and
       name if any.  */
    if (indent > 0)
        fprintf (file, " ");
    fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node)));
    dump_addr (file, " ", node);

    if (tclass == tcc_declaration)
    {
        if (DECL_NAME (node))
            fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
        else if (TREE_CODE (node) == LABEL_DECL
                 && LABEL_DECL_UID (node) != -1)
        {
            if (dump_flags & TDF_NOUID)
                fprintf (file, " L.xxxx");
            else
                fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
        }
        else
        {
            if (dump_flags & TDF_NOUID)
                fprintf (file, " %c.xxxx",
                         TREE_CODE (node) == CONST_DECL ? 'C' : 'D');
            else
                fprintf (file, " %c.%u",
                         TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
                         DECL_UID (node));
        }
    }
    else if (tclass == tcc_type)
    {
        if (TYPE_NAME (node))
        {
            if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
                fprintf (file, " %s", IDENTIFIER_POINTER (TYPE_NAME (node)));
            else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
                     && DECL_NAME (TYPE_NAME (node)))
                fprintf (file, " %s",
                         IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
        }
        if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
            fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node));
    }
    if (TREE_CODE (node) == IDENTIFIER_NODE)
        fprintf (file, " %s", IDENTIFIER_POINTER (node));

    /* We might as well always print the value of an integer or real.  */
    if (TREE_CODE (node) == INTEGER_CST)
    {
        if (TREE_OVERFLOW (node))
            fprintf (file, " overflow");

        fprintf (file, " ");
        print_dec (node, file, TYPE_SIGN (TREE_TYPE (node)));
    }
    if (TREE_CODE (node) == REAL_CST)
    {
        REAL_VALUE_TYPE d;

        if (TREE_OVERFLOW (node))
            fprintf (file, " overflow");

        d = TREE_REAL_CST (node);
        if (REAL_VALUE_ISINF (d))
            fprintf (file,  REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
        else if (REAL_VALUE_ISNAN (d))
            fprintf (file, " Nan");
        else
        {
            char string[60];
            real_to_decimal (string, &d, sizeof (string), 0, 1);
            fprintf (file, " %s", string);
        }
    }
    if (TREE_CODE (node) == FIXED_CST)
    {
        FIXED_VALUE_TYPE f;
        char string[60];

        if (TREE_OVERFLOW (node))
            fprintf (file, " overflow");

        f = TREE_FIXED_CST (node);
        fixed_to_decimal (string, &f, sizeof (string));
        fprintf (file, " %s", string);
    }

    fprintf (file, ">");
}
Пример #8
0
static inline bool
real_cst_p (tree t)
{
  return TREE_CODE (t) == REAL_CST && !TREE_OVERFLOW (t);
}
Пример #9
0
static inline bool
integer_cst_p (tree t)
{
  return TREE_CODE (t) == INTEGER_CST && !TREE_OVERFLOW (t);
}