This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Don't reapply loops flags if unnecessary in loop_optimizer_init
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: "gcc-patches at gnu dot org" <gcc-patches at gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Mon, 23 Nov 2015 00:28:13 +0100
- Subject: [PATCH] Don't reapply loops flags if unnecessary in loop_optimizer_init
- Authentication-results: sourceware.org; auth=none
- References: <5640BD31 dot 2060602 at mentor dot com> <5640FB07 dot 6010008 at mentor dot com> <alpine dot LSU dot 2 dot 11 dot 1511111159040 dot 4884 at t29 dot fhfr dot qr> <5649C41A dot 40403 at mentor dot com> <alpine dot LSU dot 2 dot 11 dot 1511161341420 dot 4884 at t29 dot fhfr dot qr> <564DA4CA dot 3020506 at mentor dot com> <alpine dot LSU dot 2 dot 11 dot 1511201128590 dot 4884 at t29 dot fhfr dot qr>
[ was: Re: [PATCH, 10/16] Add pass_oacc_kernels pass group in passes.def ]
On 20/11/15 11:37, Richard Biener wrote:
I'd rather make loop_optimizer_init do nothing
if requested flags are already set and no fixup is needed and
call the above unconditionally. Thus sth like
Index: gcc/loop-init.c
===================================================================
--- gcc/loop-init.c (revision 230649)
+++ gcc/loop-init.c (working copy)
@@ -103,7 +103,11 @@ loop_optimizer_init (unsigned flags)
calculate_dominance_info (CDI_DOMINATORS);
if (!needs_fixup)
- checking_verify_loop_structure ();
+ {
+ checking_verify_loop_structure ();
+ if (loops_state_satisfies_p (flags))
+ goto out;
+ }
/* Clear all flags. */
if (recorded_exits)
@@ -122,11 +126,12 @@ loop_optimizer_init (unsigned flags)
/* Apply flags to loops. */
apply_loop_flags (flags);
+ checking_verify_loop_structure ();
+
+out:
/* Dump loops. */
flow_loops_dump (dump_file, NULL, 1);
- checking_verify_loop_structure ();
-
timevar_pop (TV_LOOP_INIT);
}
This patch implements that approach, but the patch is slightly more
complicated because of the need to handle
LOOPS_MAY_HAVE_MULTIPLE_LATCHES differently than the rest of the flags.
Bootstrapped and reg-tested on x86_64.
OK for stage3 trunk?
Thanks,
- Tom
Don't reapply loops flags if unnecessary in loop_optimizer_init
2015-11-22 Tom de Vries <tom@codesourcery.com>
* loop-init.c (loop_optimizer_init): Don't reapply loops flags if
unnecessary.
---
gcc/loop-init.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index e32c94a..4b72cab 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -85,6 +85,8 @@ loop_optimizer_init (unsigned flags)
{
timevar_push (TV_LOOP_INIT);
+ gcc_checking_assert ((flags & (LOOP_CLOSED_SSA | LOOPS_NEED_FIXUP)) == 0);
+
if (!current_loops)
{
gcc_assert (!(cfun->curr_properties & PROP_loops));
@@ -103,7 +105,17 @@ loop_optimizer_init (unsigned flags)
calculate_dominance_info (CDI_DOMINATORS);
if (!needs_fixup)
- checking_verify_loop_structure ();
+ {
+ checking_verify_loop_structure ();
+
+ bool need_reapply
+ = (!loops_state_satisfies_p (flags
+ & (~LOOPS_MAY_HAVE_MULTIPLE_LATCHES))
+ || (loops_state_satisfies_p (LOOPS_MAY_HAVE_MULTIPLE_LATCHES)
+ && ((flags & LOOPS_MAY_HAVE_MULTIPLE_LATCHES) == 0)));
+ if (!need_reapply)
+ goto out;
+ }
/* Clear all flags. */
if (recorded_exits)
@@ -122,11 +134,12 @@ loop_optimizer_init (unsigned flags)
/* Apply flags to loops. */
apply_loop_flags (flags);
+ checking_verify_loop_structure ();
+
+ out:
/* Dump loops. */
flow_loops_dump (dump_file, NULL, 1);
- checking_verify_loop_structure ();
-
timevar_pop (TV_LOOP_INIT);
}