From patchwork Tue Jan 18 05:38:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 79250 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]) by ozlabs.org (Postfix) with SMTP id 48414B7139 for ; Tue, 18 Jan 2011 16:38:30 +1100 (EST) Received: (qmail 18526 invoked by alias); 18 Jan 2011 05:38:25 -0000 Received: (qmail 18225 invoked by uid 22791); 18 Jan 2011 05:38:23 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_TM, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Jan 2011 05:38:16 +0000 Received: by gyh20 with SMTP id 20so2296027gyh.20 for ; Mon, 17 Jan 2011 21:38:15 -0800 (PST) Received: by 10.151.26.12 with SMTP id d12mr639549ybj.45.1295329094888; Mon, 17 Jan 2011 21:38:14 -0800 (PST) Received: from napoca (adsl-99-184-93-67.dsl.austtx.sbcglobal.net [99.184.93.67]) by mx.google.com with ESMTPS id j3sm3181887ybe.11.2011.01.17.21.38.12 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 17 Jan 2011 21:38:14 -0800 (PST) Received: by napoca (sSMTP sendmail emulation); Mon, 17 Jan 2011 23:38:11 -0600 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, gcc-graphite@googlegroups.com, Sebastian Pop Subject: [PATCH 2/5] Remove duplicate close phi nodes in the canonical close phi representation. Date: Mon, 17 Jan 2011 23:38:00 -0600 Message-Id: <1295329083-27160-3-git-send-email-sebpop@gmail.com> In-Reply-To: <1295329083-27160-1-git-send-email-sebpop@gmail.com> References: <1295329083-27160-1-git-send-email-sebpop@gmail.com> X-IsSubscribed: yes 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 2011-01-17 Sebastian Pop * graphite-scop-detection.c (same_close_phi_node): New. (remove_duplicate_close_phi): New. (make_close_phi_nodes_unique): New. (canonicalize_loop_closed_ssa): Call make_close_phi_nodes_unique. --- gcc/ChangeLog.graphite | 7 ++++ gcc/graphite-scop-detection.c | 69 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 4b9572b..7cf92a5 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,12 @@ 2011-01-17 Sebastian Pop + * graphite-scop-detection.c (same_close_phi_node): New. + (remove_duplicate_close_phi): New. + (make_close_phi_nodes_unique): New. + (canonicalize_loop_closed_ssa): Call make_close_phi_nodes_unique. + +2011-01-17 Sebastian Pop + * graphite-dependences.c (new_poly_ddr): Call same_pdr_p. * graphite-poly.h (same_pdr_p): Do not expect that the PDR_TYPE of both data references to be the same. diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index c02c90a..e74e11e 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -1200,6 +1200,66 @@ limit_scops (VEC (scop_p, heap) **scops) VEC_free (sd_region, heap, regions); } +/* Returns true when P1 and P2 are close phis with the same + argument. */ + +static inline bool +same_close_phi_node (gimple p1, gimple p2) +{ + return operand_equal_p (gimple_phi_arg_def (p1, 0), + gimple_phi_arg_def (p2, 0), 0); +} + +/* Remove the close phi node at GSI and replace its rhs with the rhs + of PHI. */ + +static void +remove_duplicate_close_phi (gimple phi, gimple_stmt_iterator *gsi) +{ + gimple use_stmt; + use_operand_p use_p; + imm_use_iterator imm_iter; + tree res = gimple_phi_result (phi); + tree def = gimple_phi_result (gsi_stmt (*gsi)); + + gcc_assert (same_close_phi_node (phi, gsi_stmt (*gsi))); + + FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) + { + FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) + SET_USE (use_p, res); + + update_stmt (use_stmt); + } + + remove_phi_node (gsi, true); +} + +/* Removes all the close phi duplicates from BB. */ + +static void +make_close_phi_nodes_unique (basic_block bb) +{ + gimple_stmt_iterator psi; + + for (psi = gsi_start_phis (bb); !gsi_end_p (psi); gsi_next (&psi)) + { + gimple_stmt_iterator gsi = psi; + gimple phi = gsi_stmt (psi); + + /* At this point, PHI should be a close phi in normal form. */ + gcc_assert (gimple_phi_num_args (phi) == 1); + + /* Iterate over the next phis and remove duplicates. */ + gsi_next (&gsi); + while (!gsi_end_p (gsi)) + if (same_close_phi_node (phi, gsi_stmt (gsi))) + remove_duplicate_close_phi (phi, &gsi); + else + gsi_next (&gsi); + } +} + /* Transforms LOOP to the canonical loop closed SSA form. */ static void @@ -1214,7 +1274,10 @@ canonicalize_loop_closed_ssa (loop_p loop) bb = e->dest; if (VEC_length (edge, bb->preds) == 1) - split_block_after_labels (bb); + { + e = split_block_after_labels (bb); + make_close_phi_nodes_unique (e->src); + } else { gimple_stmt_iterator psi; @@ -1249,6 +1312,8 @@ canonicalize_loop_closed_ssa (loop_p loop) update_stmt (phi); } } + + make_close_phi_nodes_unique (close); } /* The code above does not properly handle changes in the post dominance @@ -1273,6 +1338,8 @@ canonicalize_loop_closed_ssa (loop_p loop) - the basic block containing the close phi nodes does not contain other statements. + + - there exist only one phi node per definition in the loop. */ static void