Commit 01540df2 by David Malcolm Committed by David Malcolm

tree-vrp: add "const" qualifier to various value_range pointers

gcc/ChangeLog:
	* tree-vrp.c (copy_value_range): Convert param "from" from
	"value_range *" to "const value_range *".
	(range_is_null): Likewise for param "vr".
	(range_int_cst_p): Likewise.
	(range_int_cst_singleton_p): Likewise.
	(symbolic_range_p): Likewise.
	(value_ranges_intersect_p): Likewise for both params.
	(value_range_nonnegative_p): Likewise for param "vr".
	(value_range_constant_singleton): Likewise.
	(vrp_set_zero_nonzero_bits): Likewise for param "ar".
	(extract_range_into_wide_ints): Likewise for param "vr".
	(extract_range_from_multiplicative_op): Likewise for params "vr0"
	and "vr1".
	(vrp_can_optimize_bit_op): Likewise.
	(extract_range_from_binary_expr_1): Likewise for params "vr0_" and
	"vr1_".
	(extract_range_from_unary_expr): Likewise.
	(debug_value_range): Likewise for param "vr".
	(value_range::dump): Add "const" qualifier.
	(vrp_prop::check_array_ref): Convert local "vr" from
	"value_range *" to "const value_range *".
	(vrp_prop::check_mem_ref): Likewise.
	(vrp_prop::visit_stmt): Likewise for local "old_vr".
	(vrp_intersect_ranges_1): Likewise for param "vr_1".
	(vrp_intersect_ranges): Likewise.
	(simplify_stmt_for_jump_threading): Likewise for local "vr".
	(vrp_prop::vrp_finalize): Likewise.
	* tree-vrp.h (value_range::dump): Add "const" qualifier.
	(vrp_intersect_ranges): Add "const" qualifier to params as above.
	(extract_range_from_unary_expr): Likewise.
	(value_range_constant_singleton): Likewise.
	(symbolic_range_p): Likewise.
	(copy_value_range): Likewise.
	(extract_range_from_binary_expr_1): Likewise.
	(range_int_cst_p): Likewise.
	(vrp_set_zero_nonzero_bits): Likewise.
	(range_int_cst_singleton_p): Likewise.

From-SVN: r264020
parent 66da5b53
2018-08-31 David Malcolm <dmalcolm@redhat.com>
* tree-vrp.c (copy_value_range): Convert param "from" from
"value_range *" to "const value_range *".
(range_is_null): Likewise for param "vr".
(range_int_cst_p): Likewise.
(range_int_cst_singleton_p): Likewise.
(symbolic_range_p): Likewise.
(value_ranges_intersect_p): Likewise for both params.
(value_range_nonnegative_p): Likewise for param "vr".
(value_range_constant_singleton): Likewise.
(vrp_set_zero_nonzero_bits): Likewise for param "ar".
(extract_range_into_wide_ints): Likewise for param "vr".
(extract_range_from_multiplicative_op): Likewise for params "vr0"
and "vr1".
(vrp_can_optimize_bit_op): Likewise.
(extract_range_from_binary_expr_1): Likewise for params "vr0_" and
"vr1_".
(extract_range_from_unary_expr): Likewise.
(debug_value_range): Likewise for param "vr".
(value_range::dump): Add "const" qualifier.
(vrp_prop::check_array_ref): Convert local "vr" from
"value_range *" to "const value_range *".
(vrp_prop::check_mem_ref): Likewise.
(vrp_prop::visit_stmt): Likewise for local "old_vr".
(vrp_intersect_ranges_1): Likewise for param "vr_1".
(vrp_intersect_ranges): Likewise.
(simplify_stmt_for_jump_threading): Likewise for local "vr".
(vrp_prop::vrp_finalize): Likewise.
* tree-vrp.h (value_range::dump): Add "const" qualifier.
(vrp_intersect_ranges): Add "const" qualifier to params as above.
(extract_range_from_unary_expr): Likewise.
(value_range_constant_singleton): Likewise.
(symbolic_range_p): Likewise.
(copy_value_range): Likewise.
(extract_range_from_binary_expr_1): Likewise.
(range_int_cst_p): Likewise.
(vrp_set_zero_nonzero_bits): Likewise.
(range_int_cst_singleton_p): Likewise.
2018-08-31 Vlad Lazar <vlad.lazar@arm.com> 2018-08-31 Vlad Lazar <vlad.lazar@arm.com>
* config/aarch64/arm_neon.h (vabsd_s64): New. * config/aarch64/arm_neon.h (vabsd_s64): New.
......
...@@ -442,7 +442,7 @@ set_and_canonicalize_value_range (value_range *vr, enum value_range_type t, ...@@ -442,7 +442,7 @@ set_and_canonicalize_value_range (value_range *vr, enum value_range_type t,
/* Copy value range FROM into value range TO. */ /* Copy value range FROM into value range TO. */
void void
copy_value_range (value_range *to, value_range *from) copy_value_range (value_range *to, const value_range *from)
{ {
set_value_range (to, from->type, from->min, from->max, from->equiv); set_value_range (to, from->type, from->min, from->max, from->equiv);
} }
...@@ -505,7 +505,7 @@ vrp_bitmap_equal_p (const_bitmap b1, const_bitmap b2) ...@@ -505,7 +505,7 @@ vrp_bitmap_equal_p (const_bitmap b1, const_bitmap b2)
/* Return true if VR is [0, 0]. */ /* Return true if VR is [0, 0]. */
static inline bool static inline bool
range_is_null (value_range *vr) range_is_null (const value_range *vr)
{ {
return vr->type == VR_RANGE return vr->type == VR_RANGE
&& integer_zerop (vr->min) && integer_zerop (vr->min)
...@@ -516,7 +516,7 @@ range_is_null (value_range *vr) ...@@ -516,7 +516,7 @@ range_is_null (value_range *vr)
a singleton. */ a singleton. */
bool bool
range_int_cst_p (value_range *vr) range_int_cst_p (const value_range *vr)
{ {
return (vr->type == VR_RANGE return (vr->type == VR_RANGE
&& TREE_CODE (vr->max) == INTEGER_CST && TREE_CODE (vr->max) == INTEGER_CST
...@@ -526,7 +526,7 @@ range_int_cst_p (value_range *vr) ...@@ -526,7 +526,7 @@ range_int_cst_p (value_range *vr)
/* Return true if VR is a INTEGER_CST singleton. */ /* Return true if VR is a INTEGER_CST singleton. */
bool bool
range_int_cst_singleton_p (value_range *vr) range_int_cst_singleton_p (const value_range *vr)
{ {
return (range_int_cst_p (vr) return (range_int_cst_p (vr)
&& tree_int_cst_equal (vr->min, vr->max)); && tree_int_cst_equal (vr->min, vr->max));
...@@ -535,7 +535,7 @@ range_int_cst_singleton_p (value_range *vr) ...@@ -535,7 +535,7 @@ range_int_cst_singleton_p (value_range *vr)
/* Return true if value range VR involves at least one symbol. */ /* Return true if value range VR involves at least one symbol. */
bool bool
symbolic_range_p (value_range *vr) symbolic_range_p (const value_range *vr)
{ {
return (!is_gimple_min_invariant (vr->min) return (!is_gimple_min_invariant (vr->min)
|| !is_gimple_min_invariant (vr->max)); || !is_gimple_min_invariant (vr->max));
...@@ -856,7 +856,7 @@ value_inside_range (tree val, tree min, tree max) ...@@ -856,7 +856,7 @@ value_inside_range (tree val, tree min, tree max)
*/ */
static inline bool static inline bool
value_ranges_intersect_p (value_range *vr0, value_range *vr1) value_ranges_intersect_p (const value_range *vr0, const value_range *vr1)
{ {
/* The value ranges do not intersect if the maximum of the first range is /* The value ranges do not intersect if the maximum of the first range is
less than the minimum of the second range or vice versa. less than the minimum of the second range or vice versa.
...@@ -893,7 +893,7 @@ range_includes_zero_p (const value_range *vr) ...@@ -893,7 +893,7 @@ range_includes_zero_p (const value_range *vr)
/* Return true if *VR is know to only contain nonnegative values. */ /* Return true if *VR is know to only contain nonnegative values. */
static inline bool static inline bool
value_range_nonnegative_p (value_range *vr) value_range_nonnegative_p (const value_range *vr)
{ {
/* Testing for VR_ANTI_RANGE is not useful here as any anti-range /* Testing for VR_ANTI_RANGE is not useful here as any anti-range
which would return a useful value should be encoded as a which would return a useful value should be encoded as a
...@@ -911,7 +911,7 @@ value_range_nonnegative_p (value_range *vr) ...@@ -911,7 +911,7 @@ value_range_nonnegative_p (value_range *vr)
otherwise return NULL_TREE. */ otherwise return NULL_TREE. */
tree tree
value_range_constant_singleton (value_range *vr) value_range_constant_singleton (const value_range *vr)
{ {
if (vr->type == VR_RANGE if (vr->type == VR_RANGE
&& vrp_operand_equal_p (vr->min, vr->max) && vrp_operand_equal_p (vr->min, vr->max)
...@@ -930,7 +930,7 @@ value_range_constant_singleton (value_range *vr) ...@@ -930,7 +930,7 @@ value_range_constant_singleton (value_range *vr)
bool bool
vrp_set_zero_nonzero_bits (const tree expr_type, vrp_set_zero_nonzero_bits (const tree expr_type,
value_range *vr, const value_range *vr,
wide_int *may_be_nonzero, wide_int *may_be_nonzero,
wide_int *must_be_nonzero) wide_int *must_be_nonzero)
{ {
...@@ -953,7 +953,7 @@ vrp_set_zero_nonzero_bits (const tree expr_type, ...@@ -953,7 +953,7 @@ vrp_set_zero_nonzero_bits (const tree expr_type,
*VR1 will be VR_UNDEFINED. */ *VR1 will be VR_UNDEFINED. */
static bool static bool
ranges_from_anti_range (value_range *ar, ranges_from_anti_range (const value_range *ar,
value_range *vr0, value_range *vr1) value_range *vr0, value_range *vr1)
{ {
tree type = TREE_TYPE (ar->min); tree type = TREE_TYPE (ar->min);
...@@ -999,7 +999,7 @@ ranges_from_anti_range (value_range *ar, ...@@ -999,7 +999,7 @@ ranges_from_anti_range (value_range *ar,
resulting wide ints are set to [-MIN, +MAX] for the type. */ resulting wide ints are set to [-MIN, +MAX] for the type. */
static void inline static void inline
extract_range_into_wide_ints (value_range *vr, extract_range_into_wide_ints (const value_range *vr,
signop sign, unsigned prec, signop sign, unsigned prec,
wide_int &wmin, wide_int &wmax) wide_int &wmin, wide_int &wmax)
{ {
...@@ -1033,7 +1033,8 @@ vrp_shift_undefined_p (const value_range &shifter, unsigned prec) ...@@ -1033,7 +1033,8 @@ vrp_shift_undefined_p (const value_range &shifter, unsigned prec)
static void static void
extract_range_from_multiplicative_op (value_range *vr, extract_range_from_multiplicative_op (value_range *vr,
enum tree_code code, enum tree_code code,
value_range *vr0, value_range *vr1) const value_range *vr0,
const value_range *vr1)
{ {
gcc_assert (code == MULT_EXPR gcc_assert (code == MULT_EXPR
|| code == TRUNC_DIV_EXPR || code == TRUNC_DIV_EXPR
...@@ -1073,7 +1074,7 @@ extract_range_from_multiplicative_op (value_range *vr, ...@@ -1073,7 +1074,7 @@ extract_range_from_multiplicative_op (value_range *vr,
static bool static bool
vrp_can_optimize_bit_op (value_range *vr, enum tree_code code, vrp_can_optimize_bit_op (value_range *vr, enum tree_code code,
value_range *vr0, value_range *vr1) const value_range *vr0, const value_range *vr1)
{ {
tree lower_bound, upper_bound, mask; tree lower_bound, upper_bound, mask;
if (code != BIT_AND_EXPR && code != BIT_IOR_EXPR) if (code != BIT_AND_EXPR && code != BIT_IOR_EXPR)
...@@ -1282,7 +1283,8 @@ set_value_range_with_overflow (value_range &vr, ...@@ -1282,7 +1283,8 @@ set_value_range_with_overflow (value_range &vr,
void void
extract_range_from_binary_expr_1 (value_range *vr, extract_range_from_binary_expr_1 (value_range *vr,
enum tree_code code, tree expr_type, enum tree_code code, tree expr_type,
value_range *vr0_, value_range *vr1_) const value_range *vr0_,
const value_range *vr1_)
{ {
signop sign = TYPE_SIGN (expr_type); signop sign = TYPE_SIGN (expr_type);
unsigned int prec = TYPE_PRECISION (expr_type); unsigned int prec = TYPE_PRECISION (expr_type);
...@@ -1810,7 +1812,7 @@ extract_range_from_binary_expr_1 (value_range *vr, ...@@ -1810,7 +1812,7 @@ extract_range_from_binary_expr_1 (value_range *vr,
void void
extract_range_from_unary_expr (value_range *vr, extract_range_from_unary_expr (value_range *vr,
enum tree_code code, tree type, enum tree_code code, tree type,
value_range *vr0_, tree op0_type) const value_range *vr0_, tree op0_type)
{ {
signop sign = TYPE_SIGN (type); signop sign = TYPE_SIGN (type);
unsigned int prec = TYPE_PRECISION (type); unsigned int prec = TYPE_PRECISION (type);
...@@ -1962,7 +1964,7 @@ extract_range_from_unary_expr (value_range *vr, ...@@ -1962,7 +1964,7 @@ extract_range_from_unary_expr (value_range *vr,
/* Debugging dumps. */ /* Debugging dumps. */
void dump_value_range (FILE *, const value_range *); void dump_value_range (FILE *, const value_range *);
void debug_value_range (value_range *); void debug_value_range (const value_range *);
void dump_all_value_ranges (FILE *); void dump_all_value_ranges (FILE *);
void dump_vr_equiv (FILE *, bitmap); void dump_vr_equiv (FILE *, bitmap);
void debug_vr_equiv (bitmap); void debug_vr_equiv (bitmap);
...@@ -2027,14 +2029,14 @@ dump_value_range (FILE *file, const value_range *vr) ...@@ -2027,14 +2029,14 @@ dump_value_range (FILE *file, const value_range *vr)
/* Dump value range VR to stderr. */ /* Dump value range VR to stderr. */
DEBUG_FUNCTION void DEBUG_FUNCTION void
debug_value_range (value_range *vr) debug_value_range (const value_range *vr)
{ {
dump_value_range (stderr, vr); dump_value_range (stderr, vr);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
} }
void void
value_range::dump () value_range::dump () const
{ {
debug_value_range (this); debug_value_range (this);
} }
...@@ -4214,7 +4216,7 @@ void ...@@ -4214,7 +4216,7 @@ void
vrp_prop::check_array_ref (location_t location, tree ref, vrp_prop::check_array_ref (location_t location, tree ref,
bool ignore_off_by_one) bool ignore_off_by_one)
{ {
value_range *vr = NULL; const value_range *vr = NULL;
tree low_sub, up_sub; tree low_sub, up_sub;
tree low_bound, up_bound, up_bound_p1; tree low_bound, up_bound, up_bound_p1;
...@@ -4383,7 +4385,7 @@ vrp_prop::check_mem_ref (location_t location, tree ref, ...@@ -4383,7 +4385,7 @@ vrp_prop::check_mem_ref (location_t location, tree ref,
/* The range of the byte offset into the reference. */ /* The range of the byte offset into the reference. */
offset_int offrange[2] = { 0, 0 }; offset_int offrange[2] = { 0, 0 };
value_range *vr = NULL; const value_range *vr = NULL;
/* Determine the offsets and increment OFFRANGE for the bounds of each. /* Determine the offsets and increment OFFRANGE for the bounds of each.
The loop computes the the range of the final offset for expressions The loop computes the the range of the final offset for expressions
...@@ -5273,7 +5275,7 @@ vrp_prop::visit_stmt (gimple *stmt, edge *taken_edge_p, tree *output_p) ...@@ -5273,7 +5275,7 @@ vrp_prop::visit_stmt (gimple *stmt, edge *taken_edge_p, tree *output_p)
return SSA_PROP_VARYING. */ return SSA_PROP_VARYING. */
value_range new_vr = VR_INITIALIZER; value_range new_vr = VR_INITIALIZER;
extract_range_basic (&new_vr, use_stmt); extract_range_basic (&new_vr, use_stmt);
value_range *old_vr = get_value_range (use_lhs); const value_range *old_vr = get_value_range (use_lhs);
if (old_vr->type != new_vr.type if (old_vr->type != new_vr.type
|| !vrp_operand_equal_p (old_vr->min, new_vr.min) || !vrp_operand_equal_p (old_vr->min, new_vr.min)
|| !vrp_operand_equal_p (old_vr->max, new_vr.max) || !vrp_operand_equal_p (old_vr->max, new_vr.max)
...@@ -5901,7 +5903,7 @@ intersect_ranges (enum value_range_type *vr0type, ...@@ -5901,7 +5903,7 @@ intersect_ranges (enum value_range_type *vr0type,
in *VR0. This may not be the smallest possible such range. */ in *VR0. This may not be the smallest possible such range. */
static void static void
vrp_intersect_ranges_1 (value_range *vr0, value_range *vr1) vrp_intersect_ranges_1 (value_range *vr0, const value_range *vr1)
{ {
value_range saved; value_range saved;
...@@ -5958,7 +5960,7 @@ vrp_intersect_ranges_1 (value_range *vr0, value_range *vr1) ...@@ -5958,7 +5960,7 @@ vrp_intersect_ranges_1 (value_range *vr0, value_range *vr1)
} }
void void
vrp_intersect_ranges (value_range *vr0, value_range *vr1) vrp_intersect_ranges (value_range *vr0, const value_range *vr1)
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
...@@ -6271,7 +6273,7 @@ simplify_stmt_for_jump_threading (gimple *stmt, gimple *within_stmt, ...@@ -6271,7 +6273,7 @@ simplify_stmt_for_jump_threading (gimple *stmt, gimple *within_stmt,
op = lhs_of_dominating_assert (op, bb, stmt); op = lhs_of_dominating_assert (op, bb, stmt);
value_range *vr = vr_values->get_value_range (op); const value_range *vr = vr_values->get_value_range (op);
if ((vr->type != VR_RANGE && vr->type != VR_ANTI_RANGE) if ((vr->type != VR_RANGE && vr->type != VR_ANTI_RANGE)
|| symbolic_range_p (vr)) || symbolic_range_p (vr))
return NULL_TREE; return NULL_TREE;
...@@ -6520,7 +6522,7 @@ vrp_prop::vrp_finalize (bool warn_array_bounds_p) ...@@ -6520,7 +6522,7 @@ vrp_prop::vrp_finalize (bool warn_array_bounds_p)
if (!name) if (!name)
continue; continue;
value_range *vr = get_value_range (name); const value_range *vr = get_value_range (name);
if (!name if (!name
|| (vr->type == VR_VARYING) || (vr->type == VR_VARYING)
|| (vr->type == VR_UNDEFINED) || (vr->type == VR_UNDEFINED)
......
...@@ -51,16 +51,16 @@ struct GTY((for_user)) value_range ...@@ -51,16 +51,16 @@ struct GTY((for_user)) value_range
bitmap equiv; bitmap equiv;
/* Dump value range to stderr. */ /* Dump value range to stderr. */
void dump (); void dump () const;
}; };
extern void vrp_intersect_ranges (value_range *vr0, value_range *vr1); extern void vrp_intersect_ranges (value_range *vr0, const value_range *vr1);
extern void vrp_meet (value_range *vr0, const value_range *vr1); extern void vrp_meet (value_range *vr0, const value_range *vr1);
extern void dump_value_range (FILE *, const value_range *); extern void dump_value_range (FILE *, const value_range *);
extern void extract_range_from_unary_expr (value_range *vr, extern void extract_range_from_unary_expr (value_range *vr,
enum tree_code code, enum tree_code code,
tree type, tree type,
value_range *vr0_, const value_range *vr0_,
tree op0_type); tree op0_type);
extern bool vrp_operand_equal_p (const_tree, const_tree); extern bool vrp_operand_equal_p (const_tree, const_tree);
...@@ -96,28 +96,28 @@ extern void set_and_canonicalize_value_range (value_range *, ...@@ -96,28 +96,28 @@ extern void set_and_canonicalize_value_range (value_range *,
enum value_range_type, enum value_range_type,
tree, tree, bitmap); tree, tree, bitmap);
extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap); extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap);
extern tree value_range_constant_singleton (value_range *); extern tree value_range_constant_singleton (const value_range *);
extern bool symbolic_range_p (value_range *); extern bool symbolic_range_p (const value_range *);
extern int compare_values (tree, tree); extern int compare_values (tree, tree);
extern int compare_values_warnv (tree, tree, bool *); extern int compare_values_warnv (tree, tree, bool *);
extern bool vrp_val_is_min (const_tree); extern bool vrp_val_is_min (const_tree);
extern bool vrp_val_is_max (const_tree); extern bool vrp_val_is_max (const_tree);
extern void copy_value_range (value_range *, value_range *); extern void copy_value_range (value_range *, const value_range *);
extern void set_value_range_to_value (value_range *, tree, bitmap); extern void set_value_range_to_value (value_range *, tree, bitmap);
extern void extract_range_from_binary_expr_1 (value_range *, enum tree_code, extern void extract_range_from_binary_expr_1 (value_range *, enum tree_code,
tree, value_range *, tree, const value_range *,
value_range *); const value_range *);
extern tree vrp_val_min (const_tree); extern tree vrp_val_min (const_tree);
extern tree vrp_val_max (const_tree); extern tree vrp_val_max (const_tree);
extern void set_value_range_to_null (value_range *, tree); extern void set_value_range_to_null (value_range *, tree);
extern bool range_int_cst_p (value_range *); extern bool range_int_cst_p (const value_range *);
extern int operand_less_p (tree, tree); extern int operand_less_p (tree, tree);
extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *); extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *);
extern bool find_case_label_index (gswitch *, size_t, tree, size_t *); extern bool find_case_label_index (gswitch *, size_t, tree, size_t *);
extern bool vrp_set_zero_nonzero_bits (const tree, value_range *, extern bool vrp_set_zero_nonzero_bits (const tree, const value_range *,
wide_int *, wide_int *); wide_int *, wide_int *);
extern bool overflow_comparison_p (tree_code, tree, tree, bool, tree *); extern bool overflow_comparison_p (tree_code, tree, tree, bool, tree *);
extern bool range_int_cst_singleton_p (value_range *); extern bool range_int_cst_singleton_p (const value_range *);
extern int value_inside_range (tree, tree, tree); extern int value_inside_range (tree, tree, tree);
extern tree get_single_symbol (tree, bool *, tree *); extern tree get_single_symbol (tree, bool *, tree *);
extern void maybe_set_nonzero_bits (edge, tree); extern void maybe_set_nonzero_bits (edge, tree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment