Commit f2b00d2b by Aldy Hernandez Committed by Aldy Hernandez

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
parent 49f3f450
2019-06-03 Aldy Hernandez <aldyh@redhat.com>
* 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 <wdijkstr@arm.com> 2019-06-03 Wilco Dijkstra <wdijkstr@arm.com>
PR driver/90684 PR driver/90684
......
...@@ -776,32 +776,19 @@ value_range::set (tree val) ...@@ -776,32 +776,19 @@ value_range::set (tree val)
set (VR_RANGE, val, val, NULL); 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 void
value_range_base::set_nonnull (tree type) value_range_base::set_nonzero (tree type)
{ {
tree zero = build_int_cst (type, 0); tree zero = build_int_cst (type, 0);
set (VR_ANTI_RANGE, zero, zero); set (VR_ANTI_RANGE, zero, zero);
} }
void /* Set value range VR to a ZERO range of type TYPE. */
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));
}
void void
value_range::set_null (tree type) value_range_base::set_zero (tree type)
{ {
set (build_int_cst (type, 0)); set (build_int_cst (type, 0));
} }
...@@ -830,22 +817,6 @@ vrp_bitmap_equal_p (const_bitmap b1, const_bitmap b2) ...@@ -830,22 +817,6 @@ vrp_bitmap_equal_p (const_bitmap b1, const_bitmap b2)
&& bitmap_equal_p (b1, 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 /* Return true if max and min of VR are INTEGER_CST. It's not necessary
a singleton. */ a singleton. */
...@@ -1583,9 +1554,9 @@ extract_range_from_binary_expr (value_range_base *vr, ...@@ -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 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 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. */ 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; return;
} }
...@@ -1663,9 +1634,9 @@ extract_range_from_binary_expr (value_range_base *vr, ...@@ -1663,9 +1634,9 @@ extract_range_from_binary_expr (value_range_base *vr,
If both are null, then the result is null. Otherwise they If both are null, then the result is null. Otherwise they
are varying. */ are varying. */
if (!range_includes_zero_p (&vr0) && !range_includes_zero_p (&vr1)) if (!range_includes_zero_p (&vr0) && !range_includes_zero_p (&vr1))
vr->set_nonnull (expr_type); vr->set_nonzero (expr_type);
else if (range_is_null (&vr0) && range_is_null (&vr1)) else if (vr0.zero_p () && vr1.zero_p ())
vr->set_null (expr_type); vr->set_zero (expr_type);
else else
vr->set_varying (); vr->set_varying ();
} }
...@@ -1692,9 +1663,9 @@ extract_range_from_binary_expr (value_range_base *vr, ...@@ -1692,9 +1663,9 @@ extract_range_from_binary_expr (value_range_base *vr,
&& (flag_delete_null_pointer_checks && (flag_delete_null_pointer_checks
|| (range_int_cst_p (&vr1) || (range_int_cst_p (&vr1)
&& !tree_int_cst_sign_bit (vr1.max ())))) && !tree_int_cst_sign_bit (vr1.max ()))))
vr->set_nonnull (expr_type); vr->set_nonzero (expr_type);
else if (range_is_null (&vr0) && range_is_null (&vr1)) else if (vr0.zero_p () && vr1.zero_p ())
vr->set_null (expr_type); vr->set_zero (expr_type);
else else
vr->set_varying (); vr->set_varying ();
} }
...@@ -1703,9 +1674,9 @@ extract_range_from_binary_expr (value_range_base *vr, ...@@ -1703,9 +1674,9 @@ extract_range_from_binary_expr (value_range_base *vr,
/* For pointer types, we are really only interested in asserting /* For pointer types, we are really only interested in asserting
whether the expression evaluates to non-NULL. */ whether the expression evaluates to non-NULL. */
if (!range_includes_zero_p (&vr0) && !range_includes_zero_p (&vr1)) if (!range_includes_zero_p (&vr0) && !range_includes_zero_p (&vr1))
vr->set_nonnull (expr_type); vr->set_nonzero (expr_type);
else if (range_is_null (&vr0) || range_is_null (&vr1)) else if (vr0.zero_p () || vr1.zero_p ())
vr->set_null (expr_type); vr->set_zero (expr_type);
else else
vr->set_varying (); vr->set_varying ();
} }
...@@ -1898,7 +1869,7 @@ extract_range_from_binary_expr (value_range_base *vr, ...@@ -1898,7 +1869,7 @@ extract_range_from_binary_expr (value_range_base *vr,
bool extra_range_p; bool extra_range_p;
/* Special case explicit division by zero as undefined. */ /* Special case explicit division by zero as undefined. */
if (range_is_null (&vr1)) if (vr1.zero_p ())
{ {
vr->set_undefined (); vr->set_undefined ();
return; return;
...@@ -1937,7 +1908,7 @@ extract_range_from_binary_expr (value_range_base *vr, ...@@ -1937,7 +1908,7 @@ extract_range_from_binary_expr (value_range_base *vr,
} }
else if (code == TRUNC_MOD_EXPR) else if (code == TRUNC_MOD_EXPR)
{ {
if (range_is_null (&vr1)) if (vr1.zero_p ())
{ {
vr->set_undefined (); vr->set_undefined ();
return; return;
...@@ -2141,9 +2112,9 @@ extract_range_from_unary_expr (value_range_base *vr, ...@@ -2141,9 +2112,9 @@ extract_range_from_unary_expr (value_range_base *vr,
if (POINTER_TYPE_P (type) || POINTER_TYPE_P (op0_type)) if (POINTER_TYPE_P (type) || POINTER_TYPE_P (op0_type))
{ {
if (!range_includes_zero_p (&vr0)) if (!range_includes_zero_p (&vr0))
vr->set_nonnull (type); vr->set_nonzero (type);
else if (range_is_null (&vr0)) else if (vr0.zero_p ())
vr->set_null (type); vr->set_zero (type);
else else
vr->set_varying (); vr->set_varying ();
return; return;
...@@ -6152,7 +6123,7 @@ value_range_base::union_helper (const value_range_base *vr0, ...@@ -6152,7 +6123,7 @@ value_range_base::union_helper (const value_range_base *vr0,
vr1->kind (), vr1->min (), vr1->max ()); vr1->kind (), vr1->min (), vr1->max ());
/* Work on a temporary so we can still use vr0 when union returns varying. */ /* 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); tem.set_and_canonicalize (vr0type, vr0min, vr0max);
/* Failed to find an efficient meet. Before giving up and setting /* 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, ...@@ -6162,7 +6133,7 @@ value_range_base::union_helper (const value_range_base *vr0,
&& range_includes_zero_p (vr0) == 0 && range_includes_zero_p (vr0) == 0
&& range_includes_zero_p (vr1) == 0) && range_includes_zero_p (vr1) == 0)
{ {
tem.set_nonnull (vr0->type ()); tem.set_nonzero (vr0->type ());
return tem; return tem;
} }
......
...@@ -46,8 +46,8 @@ public: ...@@ -46,8 +46,8 @@ public:
void set (value_range_kind, tree, tree); void set (value_range_kind, tree, tree);
void set (tree); void set (tree);
void set_nonnull (tree); void set_nonzero (tree);
void set_null (tree); void set_zero (tree);
enum value_range_kind kind () const; enum value_range_kind kind () const;
tree min () const; tree min () const;
...@@ -72,6 +72,7 @@ public: ...@@ -72,6 +72,7 @@ public:
bool may_contain_p (tree) const; bool may_contain_p (tree) const;
void set_and_canonicalize (enum value_range_kind, tree, tree); void set_and_canonicalize (enum value_range_kind, tree, tree);
bool zero_p () const; bool zero_p () const;
bool nonzero_p () const;
bool singleton_p (tree *result = NULL) const; bool singleton_p (tree *result = NULL) const;
void dump (FILE *) const; void dump (FILE *) const;
...@@ -118,8 +119,6 @@ class GTY((user)) value_range : public value_range_base ...@@ -118,8 +119,6 @@ class GTY((user)) value_range : public value_range_base
/* Deep-copies equiv bitmap argument. */ /* Deep-copies equiv bitmap argument. */
void set (value_range_kind, tree, tree, bitmap = NULL); void set (value_range_kind, tree, tree, bitmap = NULL);
void set (tree); 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 */;
bool operator!= (const value_range &) const /* = delete */; bool operator!= (const value_range &) const /* = delete */;
...@@ -222,6 +221,16 @@ value_range_base::zero_p () const ...@@ -222,6 +221,16 @@ value_range_base::zero_p () const
&& integer_zerop (m_max)); && 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 *);
extern void dump_value_range (FILE *, const value_range_base *); extern void dump_value_range (FILE *, const value_range_base *);
......
...@@ -118,7 +118,10 @@ vr_values::get_value_range (const_tree var) ...@@ -118,7 +118,10 @@ vr_values::get_value_range (const_tree var)
if (POINTER_TYPE_P (TREE_TYPE (sym)) if (POINTER_TYPE_P (TREE_TYPE (sym))
&& (nonnull_arg_p (sym) && (nonnull_arg_p (sym)
|| get_ptr_nonnull (var))) || 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))) else if (INTEGRAL_TYPE_P (TREE_TYPE (sym)))
{ {
get_range_info (var, *vr); get_range_info (var, *vr);
...@@ -130,7 +133,10 @@ vr_values::get_value_range (const_tree var) ...@@ -130,7 +133,10 @@ vr_values::get_value_range (const_tree var)
} }
else if (TREE_CODE (sym) == RESULT_DECL else if (TREE_CODE (sym) == RESULT_DECL
&& DECL_BY_REFERENCE (sym)) && DECL_BY_REFERENCE (sym))
vr->set_nonnull (TREE_TYPE (sym)); {
vr->set_nonzero (TREE_TYPE (sym));
vr->equiv_clear ();
}
} }
return vr; return vr;
...@@ -858,7 +864,10 @@ vr_values::extract_range_from_binary_expr (value_range *vr, ...@@ -858,7 +864,10 @@ vr_values::extract_range_from_binary_expr (value_range *vr,
|| (vr1.kind () == VR_ANTI_RANGE || (vr1.kind () == VR_ANTI_RANGE
&& vr1.min () == op0 && vr1.min () == op0
&& vr1.min () == vr1.max ()))) && 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 /* 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) ...@@ -1085,7 +1094,8 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
&& TREE_CODE (SSA_NAME_VAR (arg)) == PARM_DECL && TREE_CODE (SSA_NAME_VAR (arg)) == PARM_DECL
&& cfun->after_inlining) && cfun->after_inlining)
{ {
vr->set_null (type); vr->set_zero (type);
vr->equiv_clear ();
return; return;
} }
break; break;
...@@ -1392,7 +1402,10 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt) ...@@ -1392,7 +1402,10 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
&& gimple_stmt_nonnegative_warnv_p (stmt, &sop)) && gimple_stmt_nonnegative_warnv_p (stmt, &sop))
set_value_range_to_nonnegative (vr, type); set_value_range_to_nonnegative (vr, type);
else if (vrp_stmt_computes_nonzero (stmt)) else if (vrp_stmt_computes_nonzero (stmt))
vr->set_nonnull (type); {
vr->set_nonzero (type);
vr->equiv_clear ();
}
else else
vr->set_varying (); vr->set_varying ();
} }
......
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