From 01540df292a21926c326d8b9478becfe39459fbf Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 31 Aug 2018 16:45:47 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 40 ++++++++++++++++++++++++++++++++++++++ gcc/tree-vrp.c | 52 ++++++++++++++++++++++++++------------------------ gcc/tree-vrp.h | 22 ++++++++++----------- 3 files changed, 78 insertions(+), 36 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e5d1ad9c62..e48b983fcd5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,43 @@ +2018-08-31 David Malcolm + + * 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 * config/aarch64/arm_neon.h (vabsd_s64): New. diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index e8eb9292506..c1774dc736c 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -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. */ 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); } @@ -505,7 +505,7 @@ vrp_bitmap_equal_p (const_bitmap b1, const_bitmap b2) /* Return true if VR is [0, 0]. */ static inline bool -range_is_null (value_range *vr) +range_is_null (const value_range *vr) { return vr->type == VR_RANGE && integer_zerop (vr->min) @@ -516,7 +516,7 @@ range_is_null (value_range *vr) a singleton. */ bool -range_int_cst_p (value_range *vr) +range_int_cst_p (const value_range *vr) { return (vr->type == VR_RANGE && TREE_CODE (vr->max) == INTEGER_CST @@ -526,7 +526,7 @@ range_int_cst_p (value_range *vr) /* Return true if VR is a INTEGER_CST singleton. */ bool -range_int_cst_singleton_p (value_range *vr) +range_int_cst_singleton_p (const value_range *vr) { return (range_int_cst_p (vr) && tree_int_cst_equal (vr->min, vr->max)); @@ -535,7 +535,7 @@ range_int_cst_singleton_p (value_range *vr) /* Return true if value range VR involves at least one symbol. */ bool -symbolic_range_p (value_range *vr) +symbolic_range_p (const value_range *vr) { return (!is_gimple_min_invariant (vr->min) || !is_gimple_min_invariant (vr->max)); @@ -856,7 +856,7 @@ value_inside_range (tree val, tree min, tree max) */ 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 less than the minimum of the second range or vice versa. @@ -893,7 +893,7 @@ range_includes_zero_p (const value_range *vr) /* Return true if *VR is know to only contain nonnegative values. */ 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 which would return a useful value should be encoded as a @@ -911,7 +911,7 @@ value_range_nonnegative_p (value_range *vr) otherwise return NULL_TREE. */ tree -value_range_constant_singleton (value_range *vr) +value_range_constant_singleton (const value_range *vr) { if (vr->type == VR_RANGE && vrp_operand_equal_p (vr->min, vr->max) @@ -930,7 +930,7 @@ value_range_constant_singleton (value_range *vr) bool vrp_set_zero_nonzero_bits (const tree expr_type, - value_range *vr, + const value_range *vr, wide_int *may_be_nonzero, wide_int *must_be_nonzero) { @@ -953,7 +953,7 @@ vrp_set_zero_nonzero_bits (const tree expr_type, *VR1 will be VR_UNDEFINED. */ static bool -ranges_from_anti_range (value_range *ar, +ranges_from_anti_range (const value_range *ar, value_range *vr0, value_range *vr1) { tree type = TREE_TYPE (ar->min); @@ -999,7 +999,7 @@ ranges_from_anti_range (value_range *ar, resulting wide ints are set to [-MIN, +MAX] for the type. */ static void inline -extract_range_into_wide_ints (value_range *vr, +extract_range_into_wide_ints (const value_range *vr, signop sign, unsigned prec, wide_int &wmin, wide_int &wmax) { @@ -1033,7 +1033,8 @@ vrp_shift_undefined_p (const value_range &shifter, unsigned prec) static void extract_range_from_multiplicative_op (value_range *vr, enum tree_code code, - value_range *vr0, value_range *vr1) + const value_range *vr0, + const value_range *vr1) { gcc_assert (code == MULT_EXPR || code == TRUNC_DIV_EXPR @@ -1073,7 +1074,7 @@ extract_range_from_multiplicative_op (value_range *vr, static bool 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; if (code != BIT_AND_EXPR && code != BIT_IOR_EXPR) @@ -1282,7 +1283,8 @@ set_value_range_with_overflow (value_range &vr, void extract_range_from_binary_expr_1 (value_range *vr, 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); unsigned int prec = TYPE_PRECISION (expr_type); @@ -1810,7 +1812,7 @@ extract_range_from_binary_expr_1 (value_range *vr, void extract_range_from_unary_expr (value_range *vr, enum tree_code code, tree type, - value_range *vr0_, tree op0_type) + const value_range *vr0_, tree op0_type) { signop sign = TYPE_SIGN (type); unsigned int prec = TYPE_PRECISION (type); @@ -1962,7 +1964,7 @@ extract_range_from_unary_expr (value_range *vr, /* Debugging dumps. */ 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_vr_equiv (FILE *, bitmap); void debug_vr_equiv (bitmap); @@ -2027,14 +2029,14 @@ dump_value_range (FILE *file, const value_range *vr) /* Dump value range VR to stderr. */ DEBUG_FUNCTION void -debug_value_range (value_range *vr) +debug_value_range (const value_range *vr) { dump_value_range (stderr, vr); fprintf (stderr, "\n"); } void -value_range::dump () +value_range::dump () const { debug_value_range (this); } @@ -4214,7 +4216,7 @@ void vrp_prop::check_array_ref (location_t location, tree ref, bool ignore_off_by_one) { - value_range *vr = NULL; + const value_range *vr = NULL; tree low_sub, up_sub; tree low_bound, up_bound, up_bound_p1; @@ -4383,7 +4385,7 @@ vrp_prop::check_mem_ref (location_t location, tree ref, /* The range of the byte offset into the reference. */ 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. 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) return SSA_PROP_VARYING. */ value_range new_vr = VR_INITIALIZER; 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 || !vrp_operand_equal_p (old_vr->min, new_vr.min) || !vrp_operand_equal_p (old_vr->max, new_vr.max) @@ -5901,7 +5903,7 @@ intersect_ranges (enum value_range_type *vr0type, in *VR0. This may not be the smallest possible such range. */ 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; @@ -5958,7 +5960,7 @@ vrp_intersect_ranges_1 (value_range *vr0, value_range *vr1) } 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)) { @@ -6271,7 +6273,7 @@ simplify_stmt_for_jump_threading (gimple *stmt, gimple *within_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) || symbolic_range_p (vr)) return NULL_TREE; @@ -6520,7 +6522,7 @@ vrp_prop::vrp_finalize (bool warn_array_bounds_p) if (!name) continue; - value_range *vr = get_value_range (name); + const value_range *vr = get_value_range (name); if (!name || (vr->type == VR_VARYING) || (vr->type == VR_UNDEFINED) diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index f8c1c0c8f72..2f661613dfc 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -51,16 +51,16 @@ struct GTY((for_user)) value_range bitmap equiv; /* 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 dump_value_range (FILE *, const value_range *); extern void extract_range_from_unary_expr (value_range *vr, enum tree_code code, tree type, - value_range *vr0_, + const value_range *vr0_, tree op0_type); extern bool vrp_operand_equal_p (const_tree, const_tree); @@ -96,28 +96,28 @@ extern void set_and_canonicalize_value_range (value_range *, enum value_range_type, tree, tree, bitmap); extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap); -extern tree value_range_constant_singleton (value_range *); -extern bool symbolic_range_p (value_range *); +extern tree value_range_constant_singleton (const value_range *); +extern bool symbolic_range_p (const value_range *); extern int compare_values (tree, tree); extern int compare_values_warnv (tree, tree, bool *); extern bool vrp_val_is_min (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 extract_range_from_binary_expr_1 (value_range *, enum tree_code, - tree, value_range *, - value_range *); + tree, const value_range *, + const value_range *); extern tree vrp_val_min (const_tree); extern tree vrp_val_max (const_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 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 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 *); 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 tree get_single_symbol (tree, bool *, tree *); extern void maybe_set_nonzero_bits (edge, tree); -- 2.30.2