Commit fa8ba8b8 by Aldy Hernandez Committed by Aldy Hernandez

Revamp value_range::may_contain_p.

From-SVN: r272238
parent a7b183bf
2019-06-13 Aldy Hernandez <aldyh@redhat.com>
* gimple-loop-versioning.cc (prune_loop_conditions): Use
may_contain_p.
* tree-vrp (value_range_base::may_contain_p): Call into
value_inside_range.
(value_inside_range): Make private inside value_range_base class.
Take min/max from *this.
(range_includes_p): Remove.
* tree-vrp.h (value_range_base): Add value_inside_range.
(range_includes_p): Remove.
(range_includes_zero_p): Call may_contain_p.
* vr-values.c (compare_range_with_value): Same.
2019-06-13 Claudiu Zissulescu <claziss@synopsys.com> 2019-06-13 Claudiu Zissulescu <claziss@synopsys.com>
* doc/extend.texi (ARC Function Attributes): Update info. * doc/extend.texi (ARC Function Attributes): Update info.
......
...@@ -1488,7 +1488,7 @@ loop_versioning::prune_loop_conditions (struct loop *loop, vr_values *vrs) ...@@ -1488,7 +1488,7 @@ loop_versioning::prune_loop_conditions (struct loop *loop, vr_values *vrs)
{ {
tree name = ssa_name (i); tree name = ssa_name (i);
value_range *vr = vrs->get_value_range (name); value_range *vr = vrs->get_value_range (name);
if (vr && !range_includes_p (vr, 1)) if (vr && !vr->may_contain_p (build_one_cst (TREE_TYPE (name))))
{ {
if (dump_enabled_p ()) if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, find_loop_location (loop), dump_printf_loc (MSG_NOTE, find_loop_location (loop),
......
...@@ -287,18 +287,7 @@ value_range::set_varying () ...@@ -287,18 +287,7 @@ value_range::set_varying ()
bool bool
value_range_base::may_contain_p (tree val) const value_range_base::may_contain_p (tree val) const
{ {
if (varying_p ()) return value_inside_range (val) != 0;
return true;
if (undefined_p ())
return true;
if (m_kind == VR_ANTI_RANGE)
{
int res = value_inside_range (val, min (), max ());
return res == 0 || res == -2;
}
return value_inside_range (val, min (), max ()) != 0;
} }
void void
...@@ -1118,40 +1107,38 @@ compare_values (tree val1, tree val2) ...@@ -1118,40 +1107,38 @@ compare_values (tree val1, tree val2)
} }
/* Return 1 if VAL is inside value range MIN <= VAL <= MAX, /* Return 1 if VAL is inside value range.
0 if VAL is not inside [MIN, MAX], 0 if VAL is not inside value range.
-2 if we cannot tell either way. -2 if we cannot tell either way.
Benchmark compile/20001226-1.c compilation time after changing this Benchmark compile/20001226-1.c compilation time after changing this
function. */ function. */
int int
value_inside_range (tree val, tree min, tree max) value_range_base::value_inside_range (tree val) const
{ {
int cmp1, cmp2; int cmp1, cmp2;
cmp1 = operand_less_p (val, min); if (varying_p ())
return 1;
if (undefined_p ())
return 0;
cmp1 = operand_less_p (val, m_min);
if (cmp1 == -2) if (cmp1 == -2)
return -2; return -2;
if (cmp1 == 1) if (cmp1 == 1)
return 0; return m_kind != VR_RANGE;
cmp2 = operand_less_p (max, val); cmp2 = operand_less_p (m_max, val);
if (cmp2 == -2) if (cmp2 == -2)
return -2; return -2;
return !cmp2; if (m_kind == VR_RANGE)
} return !cmp2;
else
return !!cmp2;
/* Return TRUE if *VR includes the value X. */
bool
range_includes_p (const value_range_base *vr, HOST_WIDE_INT x)
{
if (vr->varying_p () || vr->undefined_p ())
return true;
return vr->may_contain_p (build_int_cst (vr->type (), x));
} }
/* Value range wrapper for wide_int_range_set_zero_nonzero_bits. /* Value range wrapper for wide_int_range_set_zero_nonzero_bits.
......
...@@ -97,6 +97,9 @@ protected: ...@@ -97,6 +97,9 @@ protected:
friend void gt_ggc_mx (value_range_base *&); friend void gt_ggc_mx (value_range_base *&);
friend void gt_pch_nx (value_range_base &); friend void gt_pch_nx (value_range_base &);
friend void gt_pch_nx (value_range_base *, gt_pointer_operator, void *); friend void gt_pch_nx (value_range_base *, gt_pointer_operator, void *);
private:
int value_inside_range (tree) const;
}; };
/* Note value_range cannot currently be used with GC memory, only /* Note value_range cannot currently be used with GC memory, only
...@@ -254,7 +257,6 @@ struct assert_info ...@@ -254,7 +257,6 @@ struct assert_info
extern void register_edge_assert_for (tree, edge, enum tree_code, extern void register_edge_assert_for (tree, edge, enum tree_code,
tree, tree, vec<assert_info> &); tree, tree, vec<assert_info> &);
extern bool stmt_interesting_for_vrp (gimple *); extern bool stmt_interesting_for_vrp (gimple *);
extern bool range_includes_p (const value_range_base *, HOST_WIDE_INT);
extern bool infer_value_range (gimple *, tree, tree_code *, tree *); extern bool infer_value_range (gimple *, tree, tree_code *, tree *);
extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap); extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap);
...@@ -267,7 +269,6 @@ extern int compare_values_warnv (tree, tree, bool *); ...@@ -267,7 +269,6 @@ extern int compare_values_warnv (tree, tree, bool *);
extern int operand_less_p (tree, tree); extern int operand_less_p (tree, tree);
extern bool vrp_val_is_min (const_tree); extern bool vrp_val_is_min (const_tree);
extern bool vrp_val_is_max (const_tree); extern bool vrp_val_is_max (const_tree);
extern int value_inside_range (tree, tree, tree);
extern tree vrp_val_min (const_tree); extern tree vrp_val_min (const_tree);
extern tree vrp_val_max (const_tree); extern tree vrp_val_max (const_tree);
...@@ -300,7 +301,13 @@ extern value_range_kind determine_value_range (tree, wide_int *, wide_int *); ...@@ -300,7 +301,13 @@ extern value_range_kind determine_value_range (tree, wide_int *, wide_int *);
inline bool inline bool
range_includes_zero_p (const value_range_base *vr) range_includes_zero_p (const value_range_base *vr)
{ {
return range_includes_p (vr, 0); if (vr->undefined_p ())
return false;
if (vr->varying_p ())
return true;
return vr->may_contain_p (build_zero_cst (vr->type ()));
} }
#endif /* GCC_TREE_VRP_H */ #endif /* GCC_TREE_VRP_H */
...@@ -1625,7 +1625,7 @@ compare_range_with_value (enum tree_code comp, value_range *vr, tree val, ...@@ -1625,7 +1625,7 @@ compare_range_with_value (enum tree_code comp, value_range *vr, tree val,
return NULL_TREE; return NULL_TREE;
/* ~[VAL_1, VAL_2] OP VAL is known if VAL_1 <= VAL <= VAL_2. */ /* ~[VAL_1, VAL_2] OP VAL is known if VAL_1 <= VAL <= VAL_2. */
if (value_inside_range (val, vr->min (), vr->max ()) == 1) if (!vr->may_contain_p (val))
return (comp == NE_EXPR) ? boolean_true_node : boolean_false_node; return (comp == NE_EXPR) ? boolean_true_node : boolean_false_node;
return NULL_TREE; return NULL_TREE;
......
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