aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-fold.cc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-08-08 09:05:36 +0200
committerMartin Liska <mliska@suse.cz>2022-08-08 09:05:36 +0200
commitb3a187edd33b89acf19ba46f3b8070d7c977ac57 (patch)
tree43549f6851052eb2844ea76358af30a9fd302ec5 /gcc/gimple-range-fold.cc
parent89eca196c99645ee1abefcf8b4a9dd84edd87ad6 (diff)
parent2633c8d8f338f1e2b53d3757f3edf4179bfcc218 (diff)
downloadgcc-b3a187edd33b89acf19ba46f3b8070d7c977ac57.zip
gcc-b3a187edd33b89acf19ba46f3b8070d7c977ac57.tar.gz
gcc-b3a187edd33b89acf19ba46f3b8070d7c977ac57.tar.bz2
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/gimple-range-fold.cc')
-rw-r--r--gcc/gimple-range-fold.cc56
1 files changed, 41 insertions, 15 deletions
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 6f907df..689d827 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -853,12 +853,13 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src)
}
// If SCEV is available, query if this PHI has any knonwn values.
- if (scev_initialized_p () && !POINTER_TYPE_P (TREE_TYPE (phi_def)))
+ if (scev_initialized_p ()
+ && !POINTER_TYPE_P (TREE_TYPE (phi_def)))
{
- value_range loop_range;
class loop *l = loop_containing_stmt (phi);
if (l && loop_outer (l))
{
+ Value_Range loop_range (type);
range_of_ssa_name_with_loop_info (loop_range, phi_def, l, phi, src);
if (!loop_range.varying_p ())
{
@@ -1328,37 +1329,60 @@ fold_using_range::range_of_cond_expr (vrange &r, gassign *s, fur_source &src)
return true;
}
+// Return the lower bound of R as a tree.
+
+static inline tree
+tree_lower_bound (const vrange &r, tree type)
+{
+ if (is_a <irange> (r))
+ return wide_int_to_tree (type, as_a <irange> (r).lower_bound ());
+ // ?? Handle floats when they contain endpoints.
+ return NULL;
+}
+
+// Return the upper bound of R as a tree.
+
+static inline tree
+tree_upper_bound (const vrange &r, tree type)
+{
+ if (is_a <irange> (r))
+ return wide_int_to_tree (type, as_a <irange> (r).upper_bound ());
+ // ?? Handle floats when they contain endpoints.
+ return NULL;
+}
+
// If SCEV has any information about phi node NAME, return it as a range in R.
void
-fold_using_range::range_of_ssa_name_with_loop_info (irange &r, tree name,
+fold_using_range::range_of_ssa_name_with_loop_info (vrange &r, tree name,
class loop *l, gphi *phi,
fur_source &src)
{
gcc_checking_assert (TREE_CODE (name) == SSA_NAME);
tree min, max, type = TREE_TYPE (name);
- // FIXME: Remove the supports_p() once all this can handle floats, etc.
- if (irange::supports_p (type)
- && bounds_of_var_in_loop (&min, &max, src.query (), l, phi, name))
+ if (bounds_of_var_in_loop (&min, &max, src.query (), l, phi, name))
{
- if (TREE_CODE (min) != INTEGER_CST)
+ if (!is_gimple_constant (min))
{
if (src.query ()->range_of_expr (r, min, phi) && !r.undefined_p ())
- min = wide_int_to_tree (type, r.lower_bound ());
+ min = tree_lower_bound (r, type);
else
min = vrp_val_min (type);
}
- if (TREE_CODE (max) != INTEGER_CST)
+ if (!is_gimple_constant (max))
{
if (src.query ()->range_of_expr (r, max, phi) && !r.undefined_p ())
- max = wide_int_to_tree (type, r.upper_bound ());
+ max = tree_upper_bound (r, type);
else
max = vrp_val_max (type);
}
- r.set (min, max);
+ if (min && max)
+ {
+ r.set (min, max);
+ return;
+ }
}
- else
- r.set_varying (type);
+ r.set_varying (type);
}
// -----------------------------------------------------------------------
@@ -1472,6 +1496,10 @@ fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, edge e0, edge
tree name;
basic_block bb = gimple_bb (s);
+ range_op_handler handler (s);
+ if (!handler)
+ return;
+
if (e0)
{
// If this edge is never taken, ignore it.
@@ -1500,8 +1528,6 @@ fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, edge e0, edge
tree ssa2 = gimple_range_ssa_p (gimple_range_operand2 (s));
if (ssa1 && ssa2)
{
- range_op_handler handler (s);
- gcc_checking_assert (handler);
if (e0)
{
relation_kind relation = handler.op1_op2_relation (e0_range);