From f2b00d2ba461d6dafdeccf6d93828b349b5e7f76 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Mon, 3 Jun 2019 11:28:28 +0000 Subject: [PATCH] tree-vrp.h (value_range_base::nonzero_p): New. * tree-vrp.h (value_range_base::nonzero_p): New. (value_range_base::set_nonnull): Rename to... (value_range_base::set_nonzero): ...this. (value_range_base::set_null): Rename to... (value_range_base::set_zero): ...this. (value_range::set_nonnull): Remove. (value_range::set_null): Remove. * tree-vrp.c (range_is_null): Remove. (range_is_nonnull): Remove. (extract_range_from_binary_expr): Use value_range_base::*zero_p instead of range_is_*null. (extract_range_from_unary_expr): Same. (value_range_base::set_nonnull): Rename to... (value_range_base::set_nonzero): ...this. (value_range::set_nonnull): Remove. (value_range_base::set_null): Rename to... (value_range_base::set_zero): ...this. (value_range::set_null): Remove. (extract_range_from_binary_expr): Rename set_*null uses to set_*zero. (extract_range_from_unary_expr): Same. (union_helper): Same. * vr-values.c (get_value_range): Use set_*zero instead of set_*null. (vr_values::extract_range_from_binary_expr): Same. (vr_values::extract_range_basic): Same. From-SVN: r271865 --- gcc/ChangeLog | 28 +++++++++++++++++++ gcc/tree-vrp.c | 73 +++++++++++++++---------------------------------- gcc/tree-vrp.h | 17 +++++++++--- gcc/vr-values.c | 23 ++++++++++++---- 4 files changed, 81 insertions(+), 60 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bb764ac3b47..b4c38d6ea95 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,31 @@ +2019-06-03 Aldy Hernandez + * tree-vrp.h (value_range_base::nonzero_p): New. + (value_range_base::set_nonnull): Rename to... + (value_range_base::set_nonzero): ...this. + (value_range_base::set_null): Rename to... + (value_range_base::set_zero): ...this. + (value_range::set_nonnull): Remove. + (value_range::set_null): Remove. + * tree-vrp.c (range_is_null): Remove. + (range_is_nonnull): Remove. + (extract_range_from_binary_expr): Use value_range_base::*zero_p + instead of range_is_*null. + (extract_range_from_unary_expr): Same. + (value_range_base::set_nonnull): Rename to... + (value_range_base::set_nonzero): ...this. + (value_range::set_nonnull): Remove. + (value_range_base::set_null): Rename to... + (value_range_base::set_zero): ...this. + (value_range::set_null): Remove. + (extract_range_from_binary_expr): Rename set_*null uses to + set_*zero. + (extract_range_from_unary_expr): Same. + (union_helper): Same. + * vr-values.c (get_value_range): Use set_*zero instead of + set_*null. + (vr_values::extract_range_from_binary_expr): Same. + (vr_values::extract_range_basic): Same. + 2019-06-03 Wilco Dijkstra PR driver/90684 diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 0a172719e5d..fdda64c30d5 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -776,32 +776,19 @@ value_range::set (tree val) set (VR_RANGE, val, val, NULL); } -/* Set value range VR to a non-NULL range of type TYPE. */ +/* Set value range VR to a nonzero range of type TYPE. */ void -value_range_base::set_nonnull (tree type) +value_range_base::set_nonzero (tree type) { tree zero = build_int_cst (type, 0); set (VR_ANTI_RANGE, zero, zero); } -void -value_range::set_nonnull (tree type) -{ - tree zero = build_int_cst (type, 0); - set (VR_ANTI_RANGE, zero, zero, NULL); -} - -/* Set value range VR to a NULL range of type TYPE. */ - -void -value_range_base::set_null (tree type) -{ - set (build_int_cst (type, 0)); -} +/* Set value range VR to a ZERO range of type TYPE. */ void -value_range::set_null (tree type) +value_range_base::set_zero (tree type) { set (build_int_cst (type, 0)); } @@ -830,22 +817,6 @@ vrp_bitmap_equal_p (const_bitmap b1, const_bitmap b2) && bitmap_equal_p (b1, b2))); } -/* Return true if VR is [0, 0]. */ - -static inline bool -range_is_null (const value_range_base *vr) -{ - return vr->zero_p (); -} - -static inline bool -range_is_nonnull (const value_range_base *vr) -{ - return (vr->kind () == VR_ANTI_RANGE - && vr->min () == vr->max () - && integer_zerop (vr->min ())); -} - /* Return true if max and min of VR are INTEGER_CST. It's not necessary a singleton. */ @@ -1583,9 +1554,9 @@ extract_range_from_binary_expr (value_range_base *vr, code is EXACT_DIV_EXPR. We could mask out bits in the resulting range, but then we also need to hack up vrp_union. It's just easier to special case when vr0 is ~[0,0] for EXACT_DIV_EXPR. */ - if (code == EXACT_DIV_EXPR && range_is_nonnull (&vr0)) + if (code == EXACT_DIV_EXPR && vr0.nonzero_p ()) { - vr->set_nonnull (expr_type); + vr->set_nonzero (expr_type); return; } @@ -1663,9 +1634,9 @@ extract_range_from_binary_expr (value_range_base *vr, If both are null, then the result is null. Otherwise they are varying. */ if (!range_includes_zero_p (&vr0) && !range_includes_zero_p (&vr1)) - vr->set_nonnull (expr_type); - else if (range_is_null (&vr0) && range_is_null (&vr1)) - vr->set_null (expr_type); + vr->set_nonzero (expr_type); + else if (vr0.zero_p () && vr1.zero_p ()) + vr->set_zero (expr_type); else vr->set_varying (); } @@ -1692,9 +1663,9 @@ extract_range_from_binary_expr (value_range_base *vr, && (flag_delete_null_pointer_checks || (range_int_cst_p (&vr1) && !tree_int_cst_sign_bit (vr1.max ())))) - vr->set_nonnull (expr_type); - else if (range_is_null (&vr0) && range_is_null (&vr1)) - vr->set_null (expr_type); + vr->set_nonzero (expr_type); + else if (vr0.zero_p () && vr1.zero_p ()) + vr->set_zero (expr_type); else vr->set_varying (); } @@ -1703,9 +1674,9 @@ extract_range_from_binary_expr (value_range_base *vr, /* For pointer types, we are really only interested in asserting whether the expression evaluates to non-NULL. */ if (!range_includes_zero_p (&vr0) && !range_includes_zero_p (&vr1)) - vr->set_nonnull (expr_type); - else if (range_is_null (&vr0) || range_is_null (&vr1)) - vr->set_null (expr_type); + vr->set_nonzero (expr_type); + else if (vr0.zero_p () || vr1.zero_p ()) + vr->set_zero (expr_type); else vr->set_varying (); } @@ -1898,7 +1869,7 @@ extract_range_from_binary_expr (value_range_base *vr, bool extra_range_p; /* Special case explicit division by zero as undefined. */ - if (range_is_null (&vr1)) + if (vr1.zero_p ()) { vr->set_undefined (); return; @@ -1937,7 +1908,7 @@ extract_range_from_binary_expr (value_range_base *vr, } else if (code == TRUNC_MOD_EXPR) { - if (range_is_null (&vr1)) + if (vr1.zero_p ()) { vr->set_undefined (); return; @@ -2141,9 +2112,9 @@ extract_range_from_unary_expr (value_range_base *vr, if (POINTER_TYPE_P (type) || POINTER_TYPE_P (op0_type)) { if (!range_includes_zero_p (&vr0)) - vr->set_nonnull (type); - else if (range_is_null (&vr0)) - vr->set_null (type); + vr->set_nonzero (type); + else if (vr0.zero_p ()) + vr->set_zero (type); else vr->set_varying (); return; @@ -6152,7 +6123,7 @@ value_range_base::union_helper (const value_range_base *vr0, vr1->kind (), vr1->min (), vr1->max ()); /* Work on a temporary so we can still use vr0 when union returns varying. */ - value_range tem; + value_range_base tem; tem.set_and_canonicalize (vr0type, vr0min, vr0max); /* Failed to find an efficient meet. Before giving up and setting @@ -6162,7 +6133,7 @@ value_range_base::union_helper (const value_range_base *vr0, && range_includes_zero_p (vr0) == 0 && range_includes_zero_p (vr1) == 0) { - tem.set_nonnull (vr0->type ()); + tem.set_nonzero (vr0->type ()); return tem; } diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index 9d52b428d05..435df4227f7 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -46,8 +46,8 @@ public: void set (value_range_kind, tree, tree); void set (tree); - void set_nonnull (tree); - void set_null (tree); + void set_nonzero (tree); + void set_zero (tree); enum value_range_kind kind () const; tree min () const; @@ -72,6 +72,7 @@ public: bool may_contain_p (tree) const; void set_and_canonicalize (enum value_range_kind, tree, tree); bool zero_p () const; + bool nonzero_p () const; bool singleton_p (tree *result = NULL) const; void dump (FILE *) const; @@ -118,8 +119,6 @@ class GTY((user)) value_range : public value_range_base /* Deep-copies equiv bitmap argument. */ void set (value_range_kind, tree, tree, bitmap = NULL); void set (tree); - void set_nonnull (tree); - void set_null (tree); bool operator== (const value_range &) const /* = delete */; bool operator!= (const value_range &) const /* = delete */; @@ -222,6 +221,16 @@ value_range_base::zero_p () const && integer_zerop (m_max)); } +/* Return TRUE if range is nonzero. */ + +inline bool +value_range_base::nonzero_p () const +{ + return (m_kind == VR_ANTI_RANGE + && integer_zerop (m_min) + && integer_zerop (m_max)); +} + extern void dump_value_range (FILE *, const value_range *); extern void dump_value_range (FILE *, const value_range_base *); diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 0e10aca92bb..b401516ae8e 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -118,7 +118,10 @@ vr_values::get_value_range (const_tree var) if (POINTER_TYPE_P (TREE_TYPE (sym)) && (nonnull_arg_p (sym) || get_ptr_nonnull (var))) - vr->set_nonnull (TREE_TYPE (sym)); + { + vr->set_nonzero (TREE_TYPE (sym)); + vr->equiv_clear (); + } else if (INTEGRAL_TYPE_P (TREE_TYPE (sym))) { get_range_info (var, *vr); @@ -130,7 +133,10 @@ vr_values::get_value_range (const_tree var) } else if (TREE_CODE (sym) == RESULT_DECL && DECL_BY_REFERENCE (sym)) - vr->set_nonnull (TREE_TYPE (sym)); + { + vr->set_nonzero (TREE_TYPE (sym)); + vr->equiv_clear (); + } } return vr; @@ -858,7 +864,10 @@ vr_values::extract_range_from_binary_expr (value_range *vr, || (vr1.kind () == VR_ANTI_RANGE && vr1.min () == op0 && vr1.min () == vr1.max ()))) - vr->set_nonnull (expr_type); + { + vr->set_nonzero (expr_type); + vr->equiv_clear (); + } } /* Extract range information from a unary expression CODE OP0 based on @@ -1085,7 +1094,8 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt) && TREE_CODE (SSA_NAME_VAR (arg)) == PARM_DECL && cfun->after_inlining) { - vr->set_null (type); + vr->set_zero (type); + vr->equiv_clear (); return; } break; @@ -1392,7 +1402,10 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt) && gimple_stmt_nonnegative_warnv_p (stmt, &sop)) set_value_range_to_nonnegative (vr, type); else if (vrp_stmt_computes_nonzero (stmt)) - vr->set_nonnull (type); + { + vr->set_nonzero (type); + vr->equiv_clear (); + } else vr->set_varying (); } -- 2.30.2