if (INTEGRAL_TYPE_P (TREE_TYPE (lhs)))
{
if (!vr->varying_p () && vr->constant_p ())
- set_range_info (lhs, vr->kind (),
- wi::to_wide (vr->min ()),
- wi::to_wide (vr->max ()));
+ set_range_info (lhs, *vr);
}
else if (POINTER_TYPE_P (TREE_TYPE (lhs))
&& range_includes_zero_p (vr) == 0)
wide_int min = wi::shwi (retval[0], prec);
wide_int max = wi::shwi (retval[1], prec);
- set_range_info (lhs, VR_RANGE, min, max);
+ value_range r (TREE_TYPE (lhs), min, max);
+ set_range_info (lhs, r);
setrange = true;
}
print_decs (vr[i].max, dump_file);
fprintf (dump_file, "]\n");
}
- set_range_info (ddef, vr[i].type,
- wide_int_storage::from (vr[i].min, prec,
- TYPE_SIGN (type)),
- wide_int_storage::from (vr[i].max, prec,
- TYPE_SIGN (type)));
+ value_range v (type,
+ wide_int_storage::from (vr[i].min, prec,
+ TYPE_SIGN (type)),
+ wide_int_storage::from (vr[i].max, prec,
+ TYPE_SIGN (type)),
+ vr[i].type);
+ set_range_info (ddef, v);
}
else if (POINTER_TYPE_P (TREE_TYPE (ddef))
&& vr[i].nonzero_p (TREE_TYPE (ddef)))
/* So can range-info. */
if (!POINTER_TYPE_P (TREE_TYPE (name))
&& SSA_NAME_RANGE_INFO (name))
- duplicate_ssa_name_range_info (new_tree, SSA_NAME_RANGE_TYPE (name),
- SSA_NAME_RANGE_INFO (name));
+ duplicate_ssa_name_range_info (new_tree, name);
return new_tree;
}
/* So can range-info. */
if (!POINTER_TYPE_P (TREE_TYPE (name))
&& SSA_NAME_RANGE_INFO (name))
- duplicate_ssa_name_range_info (new_tree, SSA_NAME_RANGE_TYPE (name),
- SSA_NAME_RANGE_INFO (name));
+ duplicate_ssa_name_range_info (new_tree, name);
if (SSA_NAME_IS_DEFAULT_DEF (name))
{
/* By inlining function having uninitialized variable, we might
&& SSA_NAME_RANGE_INFO (var)
&& !SSA_NAME_RANGE_INFO (copy_of[i].value)
&& var_bb == copy_of_bb)
- duplicate_ssa_name_range_info (copy_of[i].value,
- SSA_NAME_RANGE_TYPE (var),
- SSA_NAME_RANGE_INFO (var));
+ duplicate_ssa_name_range_info (copy_of[i].value, var);
}
}
wide_int wm1 = wi::minus_one (TYPE_PRECISION (integer_type_node));
wide_int w2 = wi::two (TYPE_PRECISION (integer_type_node));
- set_range_info (lhs, VR_RANGE, wm1, w2);
+ value_range vr (TREE_TYPE (lhs), wm1, w2);
+ set_range_info (lhs, vr);
}
&& SSA_NAME_RANGE_INFO (phi_result)
&& gimple_bb (SSA_NAME_DEF_STMT (new_tree)) == cond_block
&& dbg_cnt (phiopt_edge_range))
- duplicate_ssa_name_range_info (new_tree,
- SSA_NAME_RANGE_TYPE (phi_result),
- SSA_NAME_RANGE_INFO (phi_result));
+ duplicate_ssa_name_range_info (new_tree, phi_result);
/* Change the PHI argument to new. */
SET_USE (PHI_ARG_DEF_PTR (phi, e->dest_idx), new_tree);
&& r.kind () == VR_RANGE
&& !wi::neg_p (r.lower_bound (), SIGNED)
&& !wi::neg_p (r.upper_bound (), SIGNED))
- /* Just handle extension and sign-changes of all-positive ranges. */
- set_range_info (temp, VR_RANGE,
- wide_int_storage::from (r.lower_bound (),
- TYPE_PRECISION (type),
- TYPE_SIGN (type)),
- wide_int_storage::from (r.upper_bound (),
- TYPE_PRECISION (type),
- TYPE_SIGN (type)));
+ {
+ /* Just handle extension and sign-changes of all-positive ranges. */
+ range_cast (r, type);
+ set_range_info (temp, r);
+ }
}
if (dump_file && (dump_flags & TDF_DETAILS))
&& SSA_NAME_RANGE_INFO (lhs)
&& ! SSA_NAME_RANGE_INFO (sprime)
&& b == sprime_b)
- duplicate_ssa_name_range_info (sprime,
- SSA_NAME_RANGE_TYPE (lhs),
- SSA_NAME_RANGE_INFO (lhs));
+ duplicate_ssa_name_range_info (sprime, lhs);
}
/* Inhibit the use of an inserted PHI on a loop header when
if (min == max)
return wide_int_to_tree (size_type_node, min);
- set_range_info (lhs, VR_RANGE, min, max);
+ value_range vr (TREE_TYPE (lhs), min, max);
+ set_range_info (lhs, vr);
return lhs;
}
known to be unequal set the range of the result to non-zero.
This allows the call to be eliminated if its result is only
used in tests for equality to zero. */
- wide_int zero = wi::zero (TYPE_PRECISION (TREE_TYPE (lhs)));
- set_range_info (lhs, VR_ANTI_RANGE, zero, zero);
+ value_range nz;
+ nz.set_nonzero (TREE_TYPE (lhs));
+ set_range_info (lhs, nz);
return false;
}
/* When the two strings are definitely equal (such as when they
/* Store range information RANGE_TYPE, MIN, and MAX to tree ssa_name
NAME while making sure we don't store useless range info. */
-void
+static void
set_range_info (tree name, enum value_range_kind range_type,
const wide_int_ref &min, const wide_int_ref &max)
{
/* Creates a duplicate of the range_info_def at RANGE_INFO of type
RANGE_TYPE for use by the SSA name NAME. */
-void
+static void
duplicate_ssa_name_range_info (tree name, enum value_range_kind range_type,
struct range_info_def *range_info)
{
SSA_NAME_RANGE_INFO (name) = new_range_info;
}
+void
+duplicate_ssa_name_range_info (tree name, tree src)
+{
+ gcc_checking_assert (!POINTER_TYPE_P (TREE_TYPE (src)));
+ duplicate_ssa_name_range_info (name,
+ SSA_NAME_RANGE_TYPE (src),
+ SSA_NAME_RANGE_INFO (src));
+}
/* Creates a duplicate of a ssa name NAME tobe defined by statement STMT
if (VAR)
/* Sets the value range to SSA. */
-extern void set_range_info (tree, enum value_range_kind, const wide_int_ref &,
- const wide_int_ref &);
extern void set_range_info (tree, const value_range &);
extern void set_nonzero_bits (tree, const wide_int_ref &);
extern wide_int get_nonzero_bits (const_tree);
extern tree copy_ssa_name_fn (struct function *, tree, gimple *);
extern void duplicate_ssa_name_ptr_info (tree, struct ptr_info_def *);
extern tree duplicate_ssa_name_fn (struct function *, tree, gimple *);
-extern void duplicate_ssa_name_range_info (tree, enum value_range_kind,
- struct range_info_def *);
+extern void duplicate_ssa_name_range_info (tree dest, tree src);
extern void reset_flow_sensitive_info (tree);
extern void reset_flow_sensitive_info_in_bb (basic_block);
extern void release_defs (gimple *);
if (stmts != NULL && log_vf)
{
if (niters_no_overflow)
- set_range_info (niters_vector, VR_RANGE,
- wi::one (TYPE_PRECISION (type)),
- wi::rshift (wi::max_value (TYPE_PRECISION (type),
- TYPE_SIGN (type)),
- exact_log2 (const_vf),
- TYPE_SIGN (type)));
+ {
+ value_range vr (type,
+ wi::one (TYPE_PRECISION (type)),
+ wi::rshift (wi::max_value (TYPE_PRECISION (type),
+ TYPE_SIGN (type)),
+ exact_log2 (const_vf),
+ TYPE_SIGN (type)));
+ set_range_info (niters_vector, vr);
+ }
/* For VF == 1 the vector IV might also overflow so we cannot
assert a minimum value of 1. */
else if (const_vf > 1)
- set_range_info (niters_vector, VR_RANGE,
- wi::one (TYPE_PRECISION (type)),
- wi::rshift (wi::max_value (TYPE_PRECISION (type),
- TYPE_SIGN (type))
- - (const_vf - 1),
- exact_log2 (const_vf), TYPE_SIGN (type))
- + 1);
+ {
+ value_range vr (type,
+ wi::one (TYPE_PRECISION (type)),
+ wi::rshift (wi::max_value (TYPE_PRECISION (type),
+ TYPE_SIGN (type))
+ - (const_vf - 1),
+ exact_log2 (const_vf), TYPE_SIGN (type))
+ + 1);
+ set_range_info (niters_vector, vr);
+ }
}
}
*niters_vector_ptr = niters_vector;
/* It's guaranteed that vector loop bound before vectorization is at
least VF, so set range information for newly generated var. */
if (new_var_p)
- set_range_info (niters, VR_RANGE,
- wi::to_wide (build_int_cst (type, vf)),
- wi::to_wide (TYPE_MAX_VALUE (type)));
+ {
+ value_range vr (type,
+ wi::to_wide (build_int_cst (type, vf)),
+ wi::to_wide (TYPE_MAX_VALUE (type)));
+ set_range_info (niters, vr);
+ }
/* Prolog iterates at most bound_prolog times, latch iterates at
most bound_prolog - 1 times. */
&& all_imm_uses_in_stmt_or_feed_cond (var, stmt,
single_pred (bb)))
{
- set_range_info (var, SSA_NAME_RANGE_TYPE (lhs),
- SSA_NAME_RANGE_INFO (lhs)->get_min (),
- SSA_NAME_RANGE_INFO (lhs)->get_max ());
+ /* We could use duplicate_ssa_name_range_info here
+ instead of peeking inside SSA_NAME_RANGE_INFO,
+ but the aforementioned asserts that the
+ destination has no global range. This is
+ slated for removal anyhow. */
+ value_range r (TREE_TYPE (lhs),
+ SSA_NAME_RANGE_INFO (lhs)->get_min (),
+ SSA_NAME_RANGE_INFO (lhs)->get_max (),
+ SSA_NAME_RANGE_TYPE (lhs));
+ set_range_info (var, r);
maybe_set_nonzero_bits (single_pred_edge (bb), var);
}
}
gsi_insert_before (gsi, newop, GSI_SAME_STMT);
if (INTEGRAL_TYPE_P (TREE_TYPE (tem))
&& TYPE_PRECISION (TREE_TYPE (tem)) > 1)
- set_range_info (tem, VR_RANGE,
- wi::zero (TYPE_PRECISION (TREE_TYPE (tem))),
- wi::one (TYPE_PRECISION (TREE_TYPE (tem))));
+ {
+ value_range vr (TREE_TYPE (tem),
+ wi::zero (TYPE_PRECISION (TREE_TYPE (tem))),
+ wi::one (TYPE_PRECISION (TREE_TYPE (tem))));
+ set_range_info (tem, vr);
+ }
gimple_assign_set_rhs_with_ops (gsi, NOP_EXPR, tem);
}
/* Or without. */