From patchwork Mon Oct 12 15:05:01 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: 529161 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 20B091402B2 for ; Tue, 13 Oct 2015 02:06:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=qV0oIW3j; 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=vBMGmVncz6F5Em2ZR dmStuLJchSBeyo6Lbzh6kACro/XwSs7KnrJ7YgfbArFUrReITgw3hy1MIysZ+0iO /PumgCim4qX1xtxf2sO7Y6r/J5I5N9x+BgxvcAxJDgXk6D5p76iBJ1FEJ9MLmf1k /UmTonOP/culkUXQ1vDF63Ufk8= 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=r4Fqa33fXX1onEpeXeq16vu TBIQ=; b=qV0oIW3j37gdOUJE9DoZVDqmnV9OJk9D1xZJq07OchTukG5q5Qr5EVH P+mFRW8cQ4uGQY4SToQ6uyMhL1+tu1y/qcoV+XthRGhhazG8Tz0tJz2JIxIQ/wec JqrZVrsB+1jVGAyWhwiVRJdokwQsYbZQnwtnAL9O4F6HaFEi95I0= Received: (qmail 19946 invoked by alias); 12 Oct 2015 15:06:06 -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 19934 invoked by uid 89); 12 Oct 2015 15:06:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD 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; Mon, 12 Oct 2015 15:05:59 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53101) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1Zlefk-0006eC-CK for gcc-patches@gnu.org; Mon, 12 Oct 2015 11:05:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlefe-0000xc-B2 for gcc-patches@gnu.org; Mon, 12 Oct 2015 11:05:56 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:63729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlefe-0000x4-1y for gcc-patches@gnu.org; Mon, 12 Oct 2015 11:05:50 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Zlefc-0006e3-6i from Tom_deVries@mentor.com ; Mon, 12 Oct 2015 08:05:48 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Mon, 12 Oct 2015 16:05:46 +0100 Subject: [committed, gomp4, 3/6] Add pass_dominator::sese_mode_p () To: "gcc-patches@gnu.org" References: <561BC874.2020908@mentor.com> CC: Jakub Jelinek From: Tom de Vries Message-ID: <561BCC1D.50103@mentor.com> Date: Mon, 12 Oct 2015 17:05:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <561BC874.2020908@mentor.com> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 On 12/10/15 16:49, Tom de Vries wrote: > Hi, > > I've committed the following patch series to the gomp-4_0-branch. > > 1 Add pass_dominator::jump_threading_p () > 2 Add dom_walker::walk_until > 3 Add pass_dominator::sese_mode_p () > 4 Add skip_stmt parm to pass_dominator::get_sese () > 5 Add oacc kernels related infra functions > 6 Add pass_dominator_oacc_kernels > > The patch series adds a pass pass_dominator_oacc_kernels, which does the > pass_dominator optimizations (with the exception of jump threading) on > each oacc kernels region rather than on the whole function. > > Bootstrapped and reg-tested on x86_64. > > I'll post the patches individually, in reply to this email. This patch adds the ability to pass_dominator to work on a series of sese regions rather than on the entire function. Thanks, - Tom Add pass_dominator::sese_mode_p () 2015-10-12 Tom de Vries * tree-ssa-dom.c (pass_dominator::jump_threading_p): Handle sese_mode_p. (pass_dominator::sese_mode_p, pass_dominator::get_sese): New protected virtual function. (pass_dominator::execute): Handle sese_mode_p. --- gcc/tree-ssa-dom.c | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 162d9ed..7a1250e 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-dom.h" #include "gimplify.h" #include "tree-cfgcleanup.h" +#include "cfgcleanup.h" /* This file implements optimizations on the dominator tree. */ @@ -550,7 +551,17 @@ public: protected: /* Return true if pass should perform jump threading. */ - virtual bool jump_threading_p (void) { return true; } + virtual bool jump_threading_p (void) { return !sese_mode_p (); } + + /* Return true if pass should visit a series of seses rather than the whole + dominator tree. */ + virtual bool sese_mode_p (void) { return false; } + + /* In sese mode, return true if there's another sese to visit. Return the + sese to visit in SESE_ENTRY and SESE_EXIT. */ + virtual bool get_sese (basic_block *sese_entry ATTRIBUTE_UNUSED, + basic_block *sese_exit ATTRIBUTE_UNUSED) + { gcc_unreachable (); } }; // class pass_dominator @@ -583,11 +594,14 @@ pass_dominator::execute (function *fun) LOOPS_HAVE_PREHEADERS won't be needed here. */ loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES); - /* Initialize the value-handle array. */ - threadedge_initialize_values (); + if (!sese_mode_p ()) + /* Initialize the value-handle array. */ + threadedge_initialize_values (); if (jump_threading_p ()) { + gcc_assert (!sese_mode_p ()); + /* We need accurate information regarding back edges in the CFG for jump threading; this may include back edges that are not part of a single loop. */ @@ -609,7 +623,29 @@ pass_dominator::execute (function *fun) const_and_copies, avail_exprs_stack, jump_threading_p ()); - walker.walk (fun->cfg->x_entry_block_ptr); + if (!sese_mode_p ()) + walker.walk (fun->cfg->x_entry_block_ptr); + else + { + basic_block sese_entry, sese_exit; + while (get_sese (&sese_entry, &sese_exit)) + { + threadedge_initialize_values (); + avail_exprs_stack->push_marker (); + const_and_copies->push_marker (); + + walker.walk_until (sese_entry, sese_exit, true); + + avail_exprs_stack->pop_to_marker (); + const_and_copies->pop_to_marker (); + threadedge_finalize_values (); + + /* KLUDGE: The dom_walker does not allow unreachable blocks when + starting the walk, and during the dom_opt_dom_walker walk we may + produce unreachable blocks, so we need to clean them up here. */ + delete_unreachable_blocks (); + } + } { gimple_stmt_iterator gsi; @@ -709,8 +745,9 @@ pass_dominator::execute (function *fun) delete avail_exprs_stack; delete const_and_copies; - /* Free the value-handle array. */ - threadedge_finalize_values (); + if (!sese_mode_p ()) + /* Free the value-handle array. */ + threadedge_finalize_values (); return 0; } -- 1.9.1