@@ -110,9 +110,7 @@ evrp_range_analyzer::set_ssa_range_info (tree lhs, value_range_equiv *vr)
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)
@@ -4231,7 +4231,8 @@ try_substitute_return_value (gimple_stmt_iterator *gsi,
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;
}
@@ -5987,11 +5987,13 @@ ipcp_update_vr (struct cgraph_node *node)
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)))
@@ -253,8 +253,7 @@ remap_ssa_name (tree name, copy_body_data *id)
/* 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;
}
@@ -291,8 +290,7 @@ remap_ssa_name (tree name, copy_body_data *id)
/* 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
@@ -556,9 +556,7 @@ fini_copy_prop (void)
&& 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);
}
}
@@ -4862,7 +4862,8 @@ optimize_spaceship (gimple *stmt)
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);
}
@@ -416,9 +416,7 @@ replace_phi_edge_with_variable (basic_block cond_block,
&& 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);
@@ -3246,14 +3246,11 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum,
&& 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))
@@ -6304,9 +6304,7 @@ eliminate_dom_walker::eliminate_stmt (basic_block b, gimple_stmt_iterator *gsi)
&& 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
@@ -1951,7 +1951,8 @@ set_strlen_range (tree lhs, wide_int min, wide_int max,
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;
}
@@ -4343,8 +4344,9 @@ strlen_pass::handle_builtin_string_cmp ()
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
@@ -389,7 +389,7 @@ set_range_info_raw (tree name, enum value_range_kind range_type,
/* 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)
{
@@ -720,7 +720,7 @@ duplicate_ssa_name_ptr_info (tree name, struct ptr_info_def *ptr_info)
/* 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)
{
@@ -743,6 +743,14 @@ duplicate_ssa_name_range_info (tree name, enum value_range_kind range_type,
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
@@ -67,8 +67,6 @@ struct GTY ((variable_size)) range_info_def {
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);
@@ -92,8 +90,7 @@ extern void set_ptr_nonnull (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 *);
@@ -2056,22 +2056,28 @@ vect_gen_vector_loop_niters (loop_vec_info loop_vinfo, tree niters,
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;
@@ -2888,9 +2894,12 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
/* 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. */
@@ -3742,9 +3742,16 @@ vrp_asserts::remove_range_assertions ()
&& 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);
}
}
@@ -2980,9 +2980,12 @@ simplify_using_ranges::simplify_truth_ops_using_ranges
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. */