aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ch.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-09-22 06:29:20 -0700
committerIan Lance Taylor <iant@golang.org>2022-09-22 06:29:20 -0700
commit795cffe109e28b248a54b8ee583cbae48368c2a7 (patch)
tree0c12b075c51c0d5097f26953835ae540d9f2f501 /gcc/tree-ssa-loop-ch.cc
parent9f62ed218fa656607740b386c0caa03e65dcd283 (diff)
parentf35be1268c996d993ab0b4ff329734d467474445 (diff)
downloadgcc-795cffe109e28b248a54b8ee583cbae48368c2a7.zip
gcc-795cffe109e28b248a54b8ee583cbae48368c2a7.tar.gz
gcc-795cffe109e28b248a54b8ee583cbae48368c2a7.tar.bz2
Merge from trunk revision f35be1268c996d993ab0b4ff329734d467474445.
Diffstat (limited to 'gcc/tree-ssa-loop-ch.cc')
-rw-r--r--gcc/tree-ssa-loop-ch.cc25
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc
index 3b91a89..9c31688 100644
--- a/gcc/tree-ssa-loop-ch.cc
+++ b/gcc/tree-ssa-loop-ch.cc
@@ -45,11 +45,25 @@ along with GCC; see the file COPYING3. If not see
increases effectiveness of code motion optimizations, and reduces the need
for loop preconditioning. */
+/* Given a path through edge E, whose last statement is COND, return
+ the range of the solved conditional in R. */
+
+static void
+edge_range_query (irange &r, edge e, gcond *cond, gimple_ranger &ranger)
+{
+ auto_vec<basic_block> path (2);
+ path.safe_push (e->dest);
+ path.safe_push (e->src);
+ path_range_query query (ranger, path);
+ if (!query.range_of_stmt (r, cond))
+ r.set_varying (boolean_type_node);
+}
+
/* Return true if the condition on the first iteration of the loop can
be statically determined. */
static bool
-entry_loop_condition_is_static (class loop *l, path_range_query *query)
+entry_loop_condition_is_static (class loop *l, gimple_ranger *ranger)
{
edge e = loop_preheader_edge (l);
gcond *last = safe_dyn_cast <gcond *> (last_stmt (e->dest));
@@ -72,8 +86,7 @@ entry_loop_condition_is_static (class loop *l, path_range_query *query)
desired_static_value = boolean_true_node;
int_range<2> r;
- query->compute_ranges (e);
- query->range_of_stmt (r, last);
+ edge_range_query (r, e, last, *ranger);
return r == int_range<2> (desired_static_value, desired_static_value);
}
@@ -385,7 +398,7 @@ ch_base::copy_headers (function *fun)
auto_vec<std::pair<edge, loop_p> > copied;
mark_dfs_back_edges ();
- path_range_query *query = new path_range_query;
+ gimple_ranger *ranger = new gimple_ranger;
for (auto loop : loops_list (cfun, 0))
{
int initial_limit = param_max_loop_header_insns;
@@ -409,7 +422,7 @@ ch_base::copy_headers (function *fun)
iteration. */
if (optimize_loop_for_size_p (loop)
&& !loop->force_vectorize
- && !entry_loop_condition_is_static (loop, query))
+ && !entry_loop_condition_is_static (loop, ranger))
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file,
@@ -422,7 +435,7 @@ ch_base::copy_headers (function *fun)
candidates.safe_push (loop);
}
/* Do not use ranger after we change the IL and not have updated SSA. */
- delete query;
+ delete ranger;
for (auto loop : candidates)
{