public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] WIP xx.
@ 2021-12-07 16:49 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-12-07 16:49 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b5b1a500303315df32442324a19095ae7c6fc550
commit b5b1a500303315df32442324a19095ae7c6fc550
Author: Martin Liska <mliska@suse.cz>
Date: Wed Dec 1 10:03:35 2021 +0100
WIP xx.
Diff:
---
gcc/tree-ssa-loop-unswitch.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index 7b5bd8afec7..d15825908c2 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -355,30 +355,40 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop,
}
static void
-combine_range (predicate_vector &predicate_path, tree index, irange &path_range)
+merge_last (predicate_vector &predicate_path)
{
- bool first = true;
+ unswitch_predicate *last_predicate = predicate_path.last ().first;
- for (auto p: predicate_path)
+ for (int i = predicate_path.length () - 2; i >= 0; i--)
{
- unswitch_predicate *predicate = p.first;
- bool true_edge = p.second;
+ unswitch_predicate *predicate = predicate_path[i].first;
+ bool true_edge = predicate_path[i].second;
- if (operand_equal_p (predicate->lhs, index, 0))
+ if (operand_equal_p (predicate->lhs, last_predicate->lhs, 0))
{
irange &other
= true_edge ? predicate->true_range : predicate->false_range;
- if (first)
- {
- first = false;
- path_range = other;
- }
- else
- path_range.intersect (other);
+ last_predicate->true_range.intersect (other);
+ last_predicate->false_range.intersect (other);
+ return;
}
}
}
+void
+find_range_for_lhs (predicate_vector &predicate_path, tree lhs,
+ int_range_max &range)
+{
+ for (int i = predicate_path.length () - 1; i >= 0; i--)
+ {
+ unswitch_predicate *predicate = predicate_path[i].first;
+ bool true_edge = predicate_path[i].second;
+
+ if (operand_equal_p (predicate->lhs, lhs, 0))
+ range = true_edge ? predicate->true_range : predicate->false_range;
+ }
+}
+
/* Simplifies COND using checks in front of the entry of the LOOP.
Utilize both symbolic expressions and value ranges calculated by Ranger. */
@@ -404,7 +414,7 @@ evaluate_control_stmt_using_entry_checks (gimple *stmt,
{
int_range_max r;
int_range_max path_range;
- combine_range (predicate_path, lhs, path_range);
+ find_range_for_lhs (predicate_path, lhs, path_range);
if (!path_range.undefined_p ()
&& fold_range (r, stmt, path_range)
&& r.singleton_p ())
@@ -541,11 +551,13 @@ evaluate_loop_insns_for_predicate (class loop *loop, basic_block *bbs,
predicate_path.safe_push (std::make_pair (predicate, true));
unsigned true_loop_cost = evaluate_insns (loop, bbs, predicate_path,
reachable_flag);
+ merge_last (predicate_path);
predicate_path.pop ();
predicate_path.safe_push (std::make_pair (predicate, false));
unsigned false_loop_cost = evaluate_insns (loop, bbs, predicate_path,
reachable_flag);
+ merge_last (predicate_path);
predicate_path.pop ();
return true_loop_cost + false_loop_cost;
@@ -669,11 +681,13 @@ tree_unswitch_single_loop (class loop *loop, int num,
/* Invoke itself on modified loops. */
predicate_path.safe_push (std::make_pair (predicate, false));
+ merge_last (predicate_path);
changed |= simplify_loop_version (nloop, predicate_path);
tree_unswitch_single_loop (nloop, num + 1, predicate_path, budget);
predicate_path.pop ();
predicate_path.safe_push (std::make_pair (predicate, true));
+ merge_last (predicate_path);
changed |= simplify_loop_version (loop, predicate_path);
tree_unswitch_single_loop (loop, num + 1, predicate_path, budget);
predicate_path.pop ();
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] WIP xx.
@ 2021-12-08 10:17 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-12-08 10:17 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c5f005362356bb4154a3112f8d7aa6cebcc29096
commit c5f005362356bb4154a3112f8d7aa6cebcc29096
Author: Martin Liska <mliska@suse.cz>
Date: Wed Dec 1 10:03:35 2021 +0100
WIP xx.
Diff:
---
gcc/tree-ssa-loop-unswitch.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index 7b5bd8afec7..d15825908c2 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -355,30 +355,40 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop,
}
static void
-combine_range (predicate_vector &predicate_path, tree index, irange &path_range)
+merge_last (predicate_vector &predicate_path)
{
- bool first = true;
+ unswitch_predicate *last_predicate = predicate_path.last ().first;
- for (auto p: predicate_path)
+ for (int i = predicate_path.length () - 2; i >= 0; i--)
{
- unswitch_predicate *predicate = p.first;
- bool true_edge = p.second;
+ unswitch_predicate *predicate = predicate_path[i].first;
+ bool true_edge = predicate_path[i].second;
- if (operand_equal_p (predicate->lhs, index, 0))
+ if (operand_equal_p (predicate->lhs, last_predicate->lhs, 0))
{
irange &other
= true_edge ? predicate->true_range : predicate->false_range;
- if (first)
- {
- first = false;
- path_range = other;
- }
- else
- path_range.intersect (other);
+ last_predicate->true_range.intersect (other);
+ last_predicate->false_range.intersect (other);
+ return;
}
}
}
+void
+find_range_for_lhs (predicate_vector &predicate_path, tree lhs,
+ int_range_max &range)
+{
+ for (int i = predicate_path.length () - 1; i >= 0; i--)
+ {
+ unswitch_predicate *predicate = predicate_path[i].first;
+ bool true_edge = predicate_path[i].second;
+
+ if (operand_equal_p (predicate->lhs, lhs, 0))
+ range = true_edge ? predicate->true_range : predicate->false_range;
+ }
+}
+
/* Simplifies COND using checks in front of the entry of the LOOP.
Utilize both symbolic expressions and value ranges calculated by Ranger. */
@@ -404,7 +414,7 @@ evaluate_control_stmt_using_entry_checks (gimple *stmt,
{
int_range_max r;
int_range_max path_range;
- combine_range (predicate_path, lhs, path_range);
+ find_range_for_lhs (predicate_path, lhs, path_range);
if (!path_range.undefined_p ()
&& fold_range (r, stmt, path_range)
&& r.singleton_p ())
@@ -541,11 +551,13 @@ evaluate_loop_insns_for_predicate (class loop *loop, basic_block *bbs,
predicate_path.safe_push (std::make_pair (predicate, true));
unsigned true_loop_cost = evaluate_insns (loop, bbs, predicate_path,
reachable_flag);
+ merge_last (predicate_path);
predicate_path.pop ();
predicate_path.safe_push (std::make_pair (predicate, false));
unsigned false_loop_cost = evaluate_insns (loop, bbs, predicate_path,
reachable_flag);
+ merge_last (predicate_path);
predicate_path.pop ();
return true_loop_cost + false_loop_cost;
@@ -669,11 +681,13 @@ tree_unswitch_single_loop (class loop *loop, int num,
/* Invoke itself on modified loops. */
predicate_path.safe_push (std::make_pair (predicate, false));
+ merge_last (predicate_path);
changed |= simplify_loop_version (nloop, predicate_path);
tree_unswitch_single_loop (nloop, num + 1, predicate_path, budget);
predicate_path.pop ();
predicate_path.safe_push (std::make_pair (predicate, true));
+ merge_last (predicate_path);
changed |= simplify_loop_version (loop, predicate_path);
tree_unswitch_single_loop (loop, num + 1, predicate_path, budget);
predicate_path.pop ();
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] WIP xx.
@ 2021-12-08 18:25 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-12-08 18:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f42f79712b44eb5b6076cfc9dfb653427c015c85
commit f42f79712b44eb5b6076cfc9dfb653427c015c85
Author: Martin Liska <mliska@suse.cz>
Date: Wed Dec 1 10:03:35 2021 +0100
WIP xx.
Diff:
---
gcc/tree-ssa-loop-unswitch.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index bd71e9d9fbd..1bcbb2ef3b2 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -356,30 +356,40 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop,
}
static void
-combine_range (predicate_vector &predicate_path, tree index, irange &path_range)
+merge_last (predicate_vector &predicate_path)
{
- bool first = true;
+ unswitch_predicate *last_predicate = predicate_path.last ().first;
- for (auto p: predicate_path)
+ for (int i = predicate_path.length () - 2; i >= 0; i--)
{
- unswitch_predicate *predicate = p.first;
- bool true_edge = p.second;
+ unswitch_predicate *predicate = predicate_path[i].first;
+ bool true_edge = predicate_path[i].second;
- if (operand_equal_p (predicate->lhs, index, 0))
+ if (operand_equal_p (predicate->lhs, last_predicate->lhs, 0))
{
irange &other
= true_edge ? predicate->true_range : predicate->false_range;
- if (first)
- {
- first = false;
- path_range = other;
- }
- else
- path_range.intersect (other);
+ last_predicate->true_range.intersect (other);
+ last_predicate->false_range.intersect (other);
+ return;
}
}
}
+void
+find_range_for_lhs (predicate_vector &predicate_path, tree lhs,
+ int_range_max &range)
+{
+ for (int i = predicate_path.length () - 1; i >= 0; i--)
+ {
+ unswitch_predicate *predicate = predicate_path[i].first;
+ bool true_edge = predicate_path[i].second;
+
+ if (operand_equal_p (predicate->lhs, lhs, 0))
+ range = true_edge ? predicate->true_range : predicate->false_range;
+ }
+}
+
/* Simplifies COND using checks in front of the entry of the LOOP.
Utilize both symbolic expressions and value ranges calculated by Ranger. */
@@ -405,7 +415,7 @@ evaluate_control_stmt_using_entry_checks (gimple *stmt,
{
int_range_max r;
int_range_max path_range;
- combine_range (predicate_path, lhs, path_range);
+ find_range_for_lhs (predicate_path, lhs, path_range);
if (!path_range.undefined_p ()
&& fold_range (r, stmt, path_range)
&& r.singleton_p ())
@@ -542,11 +552,13 @@ evaluate_loop_insns_for_predicate (class loop *loop, basic_block *bbs,
predicate_path.safe_push (std::make_pair (predicate, true));
unsigned true_loop_cost = evaluate_insns (loop, bbs, predicate_path,
reachable_flag);
+ merge_last (predicate_path);
predicate_path.pop ();
predicate_path.safe_push (std::make_pair (predicate, false));
unsigned false_loop_cost = evaluate_insns (loop, bbs, predicate_path,
reachable_flag);
+ merge_last (predicate_path);
predicate_path.pop ();
return true_loop_cost + false_loop_cost;
@@ -670,11 +682,13 @@ tree_unswitch_single_loop (class loop *loop, int num,
/* Invoke itself on modified loops. */
predicate_path.safe_push (std::make_pair (predicate, false));
+ merge_last (predicate_path);
changed |= simplify_loop_version (nloop, predicate_path);
tree_unswitch_single_loop (nloop, num + 1, predicate_path, budget);
predicate_path.pop ();
predicate_path.safe_push (std::make_pair (predicate, true));
+ merge_last (predicate_path);
changed |= simplify_loop_version (loop, predicate_path);
tree_unswitch_single_loop (loop, num + 1, predicate_path, budget);
predicate_path.pop ();
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] WIP xx.
@ 2021-12-09 12:47 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-12-09 12:47 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:76e35cf8716b9281ee7eb5ed6f30ff1c37cae0d4
commit 76e35cf8716b9281ee7eb5ed6f30ff1c37cae0d4
Author: Martin Liska <mliska@suse.cz>
Date: Wed Dec 1 10:03:35 2021 +0100
WIP xx.
Diff:
---
gcc/tree-ssa-loop-unswitch.c | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index bd71e9d9fbd..1bcbb2ef3b2 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -356,30 +356,40 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop,
}
static void
-combine_range (predicate_vector &predicate_path, tree index, irange &path_range)
+merge_last (predicate_vector &predicate_path)
{
- bool first = true;
+ unswitch_predicate *last_predicate = predicate_path.last ().first;
- for (auto p: predicate_path)
+ for (int i = predicate_path.length () - 2; i >= 0; i--)
{
- unswitch_predicate *predicate = p.first;
- bool true_edge = p.second;
+ unswitch_predicate *predicate = predicate_path[i].first;
+ bool true_edge = predicate_path[i].second;
- if (operand_equal_p (predicate->lhs, index, 0))
+ if (operand_equal_p (predicate->lhs, last_predicate->lhs, 0))
{
irange &other
= true_edge ? predicate->true_range : predicate->false_range;
- if (first)
- {
- first = false;
- path_range = other;
- }
- else
- path_range.intersect (other);
+ last_predicate->true_range.intersect (other);
+ last_predicate->false_range.intersect (other);
+ return;
}
}
}
+void
+find_range_for_lhs (predicate_vector &predicate_path, tree lhs,
+ int_range_max &range)
+{
+ for (int i = predicate_path.length () - 1; i >= 0; i--)
+ {
+ unswitch_predicate *predicate = predicate_path[i].first;
+ bool true_edge = predicate_path[i].second;
+
+ if (operand_equal_p (predicate->lhs, lhs, 0))
+ range = true_edge ? predicate->true_range : predicate->false_range;
+ }
+}
+
/* Simplifies COND using checks in front of the entry of the LOOP.
Utilize both symbolic expressions and value ranges calculated by Ranger. */
@@ -405,7 +415,7 @@ evaluate_control_stmt_using_entry_checks (gimple *stmt,
{
int_range_max r;
int_range_max path_range;
- combine_range (predicate_path, lhs, path_range);
+ find_range_for_lhs (predicate_path, lhs, path_range);
if (!path_range.undefined_p ()
&& fold_range (r, stmt, path_range)
&& r.singleton_p ())
@@ -542,11 +552,13 @@ evaluate_loop_insns_for_predicate (class loop *loop, basic_block *bbs,
predicate_path.safe_push (std::make_pair (predicate, true));
unsigned true_loop_cost = evaluate_insns (loop, bbs, predicate_path,
reachable_flag);
+ merge_last (predicate_path);
predicate_path.pop ();
predicate_path.safe_push (std::make_pair (predicate, false));
unsigned false_loop_cost = evaluate_insns (loop, bbs, predicate_path,
reachable_flag);
+ merge_last (predicate_path);
predicate_path.pop ();
return true_loop_cost + false_loop_cost;
@@ -670,11 +682,13 @@ tree_unswitch_single_loop (class loop *loop, int num,
/* Invoke itself on modified loops. */
predicate_path.safe_push (std::make_pair (predicate, false));
+ merge_last (predicate_path);
changed |= simplify_loop_version (nloop, predicate_path);
tree_unswitch_single_loop (nloop, num + 1, predicate_path, budget);
predicate_path.pop ();
predicate_path.safe_push (std::make_pair (predicate, true));
+ merge_last (predicate_path);
changed |= simplify_loop_version (loop, predicate_path);
tree_unswitch_single_loop (loop, num + 1, predicate_path, budget);
predicate_path.pop ();
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-09 12:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 16:49 [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] WIP xx Martin Liska
2021-12-08 10:17 Martin Liska
2021-12-08 18:25 Martin Liska
2021-12-09 12:47 Martin Liska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).