From patchwork Wed Jun 24 08:51:02 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: 488011 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 1A9BC1402BA for ; Wed, 24 Jun 2015 18:51:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=WRm5ShFE; 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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=k0RV0eAhteTzaaPeQVkXqNujOZb0P1RPijfXWrDmAH2 9V76J87aHk7Vlj9p0diPPBKQmr/Fgsk9PSPwY9oG794lpriWLexa1bT8+D2f8fAu UgJqfdXzjUOQ+77xwhiFZ0HAVLoG4s7j7/Ag85uVXGvTK9hqva5ONwAwOCIEOf4E = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=joyIee5rfJu7avjBgHMoriFM5CM=; b=WRm5ShFEf2YgPUX/q qomR0sHLeigS5vauJyj7kazWVONs6+cDB4JrgAkQwDDTFVrDJQBGsaHukAmQx8gt c5z1OBzh1POlYGlhI0SLf0TUY7TzIbdimlmibYYer7Yu0XN8ju1mlak1aIjIEgtL duqyW789PtkEN3J0X+4E8fVuWw= Received: (qmail 19018 invoked by alias); 24 Jun 2015 08:51:20 -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 19009 invoked by uid 89); 24 Jun 2015 08:51:20 -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, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 24 Jun 2015 08:51:18 +0000 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 1Z7gOn-0006d7-Ij from Tom_deVries@mentor.com ; Wed, 24 Jun 2015 01:51:13 -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; Wed, 24 Jun 2015 09:51:11 +0100 Message-ID: <558A6F76.4040006@mentor.com> Date: Wed, 24 Jun 2015 10:51:02 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: GCC Patches CC: Jakub Jelinek , Richard Biener Subject: [gomp4, committed] Move rewrite_virtuals_into_loop_closed_ssa to tree-ssa-loop-manip.c Hi, this patch moves rewrite_virtuals_into_loop_closed_ssa to tree-ssa-loop-manip.c, as requested here: https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01264.html . Thanks, - Tom Move rewrite_virtuals_into_loop_closed_ssa to tree-ssa-loop-manip.c 2015-06-18 Tom de Vries * tree-parloops.c (replace_uses_in_bbs_by) (rewrite_virtuals_into_loop_closed_ssa): Move to ... * tree-ssa-loop-manip.c: here. * tree-ssa-loop-manip.h (rewrite_virtuals_into_loop_closed_ssa): Declare. --- gcc/tree-parloops.c | 87 ----------------------------------------------- gcc/tree-ssa-loop-manip.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++ gcc/tree-ssa-loop-manip.h | 1 + 3 files changed, 88 insertions(+), 87 deletions(-) diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 0661b78..a9d8c2a 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -1507,93 +1507,6 @@ replace_uses_in_bb_by (tree name, tree val, basic_block bb) } } -/* Replace uses of NAME by VAL in blocks BBS. */ - -static void -replace_uses_in_bbs_by (tree name, tree val, bitmap bbs) -{ - gimple use_stmt; - imm_use_iterator imm_iter; - - FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, name) - { - if (!bitmap_bit_p (bbs, gimple_bb (use_stmt)->index)) - continue; - - use_operand_p use_p; - FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) - SET_USE (use_p, val); - } -} - -/* Ensure a virtual phi is present in the exit block, if LOOP contains a vdef. - In other words, ensure loop-closed ssa normal form for virtuals. */ - -static void -rewrite_virtuals_into_loop_closed_ssa (struct loop *loop) -{ - gphi *phi; - edge exit = single_dom_exit (loop); - - phi = NULL; - for (gphi_iterator gsi = gsi_start_phis (loop->header); - !gsi_end_p (gsi); - gsi_next (&gsi)) - { - if (virtual_operand_p (PHI_RESULT (gsi.phi ()))) - { - phi = gsi.phi (); - break; - } - } - - if (phi == NULL) - return; - - tree final_loop = PHI_ARG_DEF_FROM_EDGE (phi, single_succ_edge (loop->latch)); - - phi = NULL; - for (gphi_iterator gsi = gsi_start_phis (exit->dest); - !gsi_end_p (gsi); - gsi_next (&gsi)) - { - if (virtual_operand_p (PHI_RESULT (gsi.phi ()))) - { - phi = gsi.phi (); - break; - } - } - - if (phi != NULL) - { - tree final_exit = PHI_ARG_DEF_FROM_EDGE (phi, exit); - gcc_assert (operand_equal_p (final_loop, final_exit, 0)); - return; - } - - tree res_new = copy_ssa_name (final_loop, NULL); - gphi *nphi = create_phi_node (res_new, exit->dest); - - /* Gather the bbs dominated by the exit block. */ - bitmap exit_dominated = BITMAP_ALLOC (NULL); - bitmap_set_bit (exit_dominated, exit->dest->index); - vec exit_dominated_vec - = get_dominated_by (CDI_DOMINATORS, exit->dest); - - int i; - basic_block dom_bb; - FOR_EACH_VEC_ELT (exit_dominated_vec, i, dom_bb) - bitmap_set_bit (exit_dominated, dom_bb->index); - - exit_dominated_vec.release (); - - replace_uses_in_bbs_by (final_loop, res_new, exit_dominated); - - add_phi_arg (nphi, final_loop, exit, UNKNOWN_LOCATION); - - BITMAP_FREE (exit_dominated); -} - /* Do transformation from: : diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index 228fac6..1150e6c 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -569,6 +569,93 @@ rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag) free (use_blocks); } +/* Replace uses of NAME by VAL in blocks BBS. */ + +static void +replace_uses_in_bbs_by (tree name, tree val, bitmap bbs) +{ + gimple use_stmt; + imm_use_iterator imm_iter; + + FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, name) + { + if (!bitmap_bit_p (bbs, gimple_bb (use_stmt)->index)) + continue; + + use_operand_p use_p; + FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) + SET_USE (use_p, val); + } +} + +/* Ensure a virtual phi is present in the exit block, if LOOP contains a vdef. + In other words, ensure loop-closed ssa normal form for virtuals. */ + +void +rewrite_virtuals_into_loop_closed_ssa (struct loop *loop) +{ + gphi *phi; + edge exit = single_dom_exit (loop); + + phi = NULL; + for (gphi_iterator gsi = gsi_start_phis (loop->header); + !gsi_end_p (gsi); + gsi_next (&gsi)) + { + if (virtual_operand_p (PHI_RESULT (gsi.phi ()))) + { + phi = gsi.phi (); + break; + } + } + + if (phi == NULL) + return; + + tree final_loop = PHI_ARG_DEF_FROM_EDGE (phi, single_succ_edge (loop->latch)); + + phi = NULL; + for (gphi_iterator gsi = gsi_start_phis (exit->dest); + !gsi_end_p (gsi); + gsi_next (&gsi)) + { + if (virtual_operand_p (PHI_RESULT (gsi.phi ()))) + { + phi = gsi.phi (); + break; + } + } + + if (phi != NULL) + { + tree final_exit = PHI_ARG_DEF_FROM_EDGE (phi, exit); + gcc_assert (operand_equal_p (final_loop, final_exit, 0)); + return; + } + + tree res_new = copy_ssa_name (final_loop, NULL); + gphi *nphi = create_phi_node (res_new, exit->dest); + + /* Gather the bbs dominated by the exit block. */ + bitmap exit_dominated = BITMAP_ALLOC (NULL); + bitmap_set_bit (exit_dominated, exit->dest->index); + vec exit_dominated_vec + = get_dominated_by (CDI_DOMINATORS, exit->dest); + + int i; + basic_block dom_bb; + FOR_EACH_VEC_ELT (exit_dominated_vec, i, dom_bb) + bitmap_set_bit (exit_dominated, dom_bb->index); + + exit_dominated_vec.release (); + + replace_uses_in_bbs_by (final_loop, res_new, exit_dominated); + + add_phi_arg (nphi, final_loop, exit, UNKNOWN_LOCATION); + + BITMAP_FREE (exit_dominated); +} + /* Check invariants of the loop closed ssa form for the USE in BB. */ static void diff --git a/gcc/tree-ssa-loop-manip.h b/gcc/tree-ssa-loop-manip.h index ad0c381..9285718 100644 --- a/gcc/tree-ssa-loop-manip.h +++ b/gcc/tree-ssa-loop-manip.h @@ -25,6 +25,7 @@ typedef void (*transform_callback)(struct loop *, void *); extern void create_iv (tree, tree, tree, struct loop *, gimple_stmt_iterator *, bool, tree *, tree *); extern void rewrite_into_loop_closed_ssa (bitmap, unsigned); +extern void rewrite_virtuals_into_loop_closed_ssa (struct loop *); extern void verify_loop_closed_ssa (bool); extern basic_block split_loop_exit_edge (edge); extern basic_block ip_end_pos (struct loop *); -- 1.9.1