From patchwork Sun Nov 22 23:28:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 547361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 495B0140213 for ; Mon, 23 Nov 2015 10:29:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=gv+MlD7s; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=gJMJo7Gp6sYUPc3wM MAd7TC8V137p9NpsMhyPxGz+yNrBqXU6aBdpOleN8B2XH0LGEsNGgN6b0wjv7kl2 bi77UR97y49k2PjnnyMVgMKR+XAVozEVpt4uHmtWKLkiy+BZpM5v11PC1bO+72ET Yb9VQNLmCqIU7iurnytW1UH5uQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=AWENA9pm7zOtUra8NAV56iX 3sWc=; b=gv+MlD7sKamdYZD8FYOd3dbfVrlnGG3QGqjF1JdQNrjbleBREPNqupF LSNKH7a1S3wBR8dUtjemQGZ1S89vTxs2AuHTaPZp4NlervEMV1AA1PX0wDxyI3+x UFZNYBqrGIqOj+HHBAEV9cGmllFAK5BZsTiCSND7wEqR2F5oDcyE= Received: (qmail 12557 invoked by alias); 22 Nov 2015 23:29:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12545 invoked by uid 89); 22 Nov 2015 23:29:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 22 Nov 2015 23:29:10 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40942) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1a0e4B-0003ah-GU for gcc-patches@gnu.org; Sun, 22 Nov 2015 18:29:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0e46-0002aL-RS for gcc-patches@gnu.org; Sun, 22 Nov 2015 18:29:06 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:57403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0e46-0002aF-LL for gcc-patches@gnu.org; Sun, 22 Nov 2015 18:29:02 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1a0e45-0003sc-Qw from Tom_deVries@mentor.com ; Sun, 22 Nov 2015 15:29:02 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Sun, 22 Nov 2015 23:29:00 +0000 Subject: [PATCH] Don't reapply loops flags if unnecessary in loop_optimizer_init To: Richard Biener References: <5640BD31.2060602@mentor.com> <5640FB07.6010008@mentor.com> <5649C41A.40403@mentor.com> <564DA4CA.3020506@mentor.com> CC: "gcc-patches@gnu.org" , Jakub Jelinek From: Tom de Vries Message-ID: <56524F8D.9090003@mentor.com> Date: Mon, 23 Nov 2015 00:28:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 [ 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 * 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); }