public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/hubicka/heads/honza-gcc-benchmark-branch-v2)] Add early loop unrolling.
@ 2021-10-07 10:11 Jan Hubicka
0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2021-10-07 10:11 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6edc7d3ba0654401089a627b9272952f66cd659f
commit 6edc7d3ba0654401089a627b9272952f66cd659f
Author: Jan Hubicka <jh@suse.cz>
Date: Thu Oct 7 12:10:56 2021 +0200
Add early loop unrolling.
Diff:
---
gcc/ipa-modref-tree.h | 7 +++++-
gcc/opts.c | 1 +
gcc/passes.def | 1 +
gcc/tree-pass.h | 1 +
gcc/tree-ssa-loop-ivcanon.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/gcc/ipa-modref-tree.h b/gcc/ipa-modref-tree.h
index 6a9ed5ce54b..f3f6e123d67 100644
--- a/gcc/ipa-modref-tree.h
+++ b/gcc/ipa-modref-tree.h
@@ -616,7 +616,12 @@ private:
if (n->contains (*a))
found = true;
- if (!found && n->merge (*a, false))
+ else if (a->contains (n))
+ {
+ *n = a;
+ found = true;
+ }
+ else if (n->merge (*a, false))
found = restart = true;
if (found)
{
diff --git a/gcc/opts.c b/gcc/opts.c
index fae3a121146..1d2d22d7a3f 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -561,6 +561,7 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_1_PLUS, OPT_fforward_propagate, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fguess_branch_probability, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 },
+ { OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fipa_reference_addressable, NULL, 1 },
{ OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 },
diff --git a/gcc/passes.def b/gcc/passes.def
index d7a1f8c97a6..64b4b7ec45f 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -83,6 +83,7 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_forwprop);
NEXT_PASS (pass_early_thread_jumps);
NEXT_PASS (pass_sra_early);
+ NEXT_PASS (pass_early_complete_unrolli);
/* pass_build_ealias is a dummy pass that ensures that we
execute TODO_rebuild_alias at this point. */
NEXT_PASS (pass_build_ealias);
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index eb75eb17951..a3959322b29 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -389,6 +389,7 @@ extern gimple_opt_pass *make_pass_simduid_cleanup (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_slp_vectorize (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_complete_unroll (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_complete_unrolli (gcc::context *ctxt);
+extern gimple_opt_pass *make_pass_early_complete_unrolli (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_pre_slp_scalar_cleanup (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_parallelize_loops (gcc::context *ctxt);
extern gimple_opt_pass *make_pass_loop_prefetch (gcc::context *ctxt);
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 8d8791f837e..84c79e84ad8 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -1673,3 +1673,60 @@ make_pass_complete_unrolli (gcc::context *ctxt)
}
+
+/* Complete unrolling of inner loops. */
+
+namespace {
+
+const pass_data pass_data_early_complete_unrolli =
+{
+ GIMPLE_PASS, /* type */
+ "early-cunrolli", /* name */
+ OPTGROUP_LOOP, /* optinfo_flags */
+ TV_COMPLETE_UNROLL, /* tv_id */
+ ( PROP_cfg | PROP_ssa ), /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ 0, /* todo_flags_finish */
+};
+
+class pass_early_complete_unrolli : public gimple_opt_pass
+{
+public:
+ pass_early_complete_unrolli (gcc::context *ctxt)
+ : gimple_opt_pass (pass_data_early_complete_unrolli, ctxt)
+ {}
+
+ /* opt_pass methods: */
+ virtual bool gate (function *) { return optimize >= 2; }
+ virtual unsigned int execute (function *);
+
+}; // class pass_early_complete_unrolli
+
+unsigned int
+pass_early_complete_unrolli::execute (function *fun)
+{
+ unsigned ret = 0;
+
+ loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
+ if (number_of_loops (fun) > 1)
+ {
+ scev_initialize ();
+ ret = tree_unroll_loops_completely (false, false);
+ scev_finalize ();
+ }
+ loop_optimizer_finalize ();
+
+ return ret;
+}
+
+} // anon namespace
+
+gimple_opt_pass *
+make_pass_early_complete_unrolli (gcc::context *ctxt)
+{
+ return new pass_early_complete_unrolli (ctxt);
+}
+
+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-07 10:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-07 10:11 [gcc(refs/users/hubicka/heads/honza-gcc-benchmark-branch-v2)] Add early loop unrolling Jan Hubicka
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).