Commit 523fe5b6 by Aldy Hernandez Committed by Aldy Hernandez

Disentangle range_fold_*ary_expr() into various independent pieces.

From-SVN: r276654
parent 3faf75d4
2019-10-07 Aldy Hernandez <aldyh@redhat.com>
* ipa-prop.c (ipa_vr::nonzero_p): New.
(ipcp_update_vr): Use nonzero_p instead of open-coding check for
non-zero range.
* ipa-prop.h (class ipa_vr): Add nonzero_p.
* tree-vrp.c (range_has_numeric_bounds_p): New.
(range_int_cst_p): Use range_has_numeric_bounds_p.
(get_range_op_handler): New.
(supported_types_p): New.
(defined_ranges_p): New.
(drop_undefines_to_varying): New.
(range_fold_binary_symbolics_p): New.
(range_fold_unary_symbolics_p): New.
(range_fold_unary_expr): Extract out into above functions.
(range_fold_binary_expr): Same.
(value_range_base::normalize_addresses): New.
(value_range_base::normalize_symbolics): Normalize addresses.
* tree-vrp.h (class value_range_base): Add normalize_addresses.
2019-10-07 Aldy Hernandez <aldyh@redhat.com>
* tree-vrp.c (value_range_base::singleton_p): Use
value_range_base::num_pairs instead of vrp_val_is* to check
if a range has one sub-range.
......
......@@ -5109,6 +5109,18 @@ ipcp_update_bits (struct cgraph_node *node)
}
}
bool
ipa_vr::nonzero_p (tree expr_type) const
{
if (type == VR_ANTI_RANGE && wi::eq_p (min, 0) && wi::eq_p (max, 0))
return true;
unsigned prec = TYPE_PRECISION (expr_type);
return (type == VR_RANGE
&& wi::eq_p (min, wi::one (prec))
&& wi::eq_p (max, wi::max_value (prec, TYPE_SIGN (expr_type))));
}
/* Update value range of formal parameters as described in
ipcp_transformation. */
......@@ -5181,9 +5193,7 @@ ipcp_update_vr (struct cgraph_node *node)
TYPE_SIGN (type)));
}
else if (POINTER_TYPE_P (TREE_TYPE (ddef))
&& vr[i].type == VR_ANTI_RANGE
&& wi::eq_p (vr[i].min, 0)
&& wi::eq_p (vr[i].max, 0))
&& vr[i].nonzero_p (TREE_TYPE (ddef)))
{
if (dump_file)
fprintf (dump_file, "Setting nonnull for %u\n", i);
......
......@@ -165,6 +165,7 @@ public:
enum value_range_kind type;
wide_int min;
wide_int max;
bool nonzero_p (tree) const;
};
/* A jump function for a callsite represents the values passed as actual
......
......@@ -86,6 +86,7 @@ public:
static bool supports_type_p (tree);
value_range_base normalize_symbolics () const;
value_range_base normalize_addresses () const;
static const unsigned int m_max_pairs = 2;
bool contains_p (tree) const;
......
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