+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>
PR driver/90684
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));
}
&& 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. */
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;
}
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 ();
}
&& (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 ();
}
/* 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 ();
}
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;
}
else if (code == TRUNC_MOD_EXPR)
{
- if (range_is_null (&vr1))
+ if (vr1.zero_p ())
{
vr->set_undefined ();
return;
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;
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
&& range_includes_zero_p (vr0) == 0
&& range_includes_zero_p (vr1) == 0)
{
- tem.set_nonnull (vr0->type ());
+ tem.set_nonzero (vr0->type ());
return tem;
}
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;
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;
/* 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 */;
&& 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 *);
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);
}
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;
|| (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
&& TREE_CODE (SSA_NAME_VAR (arg)) == PARM_DECL
&& cfun->after_inlining)
{
- vr->set_null (type);
+ vr->set_zero (type);
+ vr->equiv_clear ();
return;
}
break;
&& 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 ();
}