From patchwork Tue Jul 27 20:03:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 60043 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 8FC28B70AB for ; Wed, 28 Jul 2010 06:04:22 +1000 (EST) Received: (qmail 4700 invoked by alias); 27 Jul 2010 20:04:18 -0000 Received: (qmail 4250 invoked by uid 22791); 27 Jul 2010 20:04:14 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_TM, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-vw0-f47.google.com (HELO mail-vw0-f47.google.com) (209.85.212.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Jul 2010 20:04:06 +0000 Received: by vws13 with SMTP id 13so4059399vws.20 for ; Tue, 27 Jul 2010 13:04:04 -0700 (PDT) Received: by 10.220.161.203 with SMTP id s11mr5395577vcx.55.1280261044452; Tue, 27 Jul 2010 13:04:04 -0700 (PDT) Received: from napoca ([163.181.251.115]) by mx.google.com with ESMTPS id w31sm3034404vbs.5.2010.07.27.13.04.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 27 Jul 2010 13:04:04 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Tue, 27 Jul 2010 15:04:01 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: gcc-graphite@googlegroups.com, Sebastian Pop Subject: [PATCH] Call scev_reset_htab when Graphite out-of-SSA has changed something. Date: Tue, 27 Jul 2010 15:03:54 -0500 Message-Id: <1280261034-22335-2-git-send-email-sebpop@gmail.com> In-Reply-To: <1280261034-22335-1-git-send-email-sebpop@gmail.com> References: <1280261034-22335-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 2010-07-27 Sebastian Pop * graphite-sese-to-poly.c (rewrite_cross_bb_scalar_deps): Returns a bool. (rewrite_commutative_reductions_out_of_ssa_close_phi): Same. (rewrite_commutative_reductions_out_of_ssa_loop): Same. (rewrite_cross_bb_scalar_deps_out_of_ssa): Call scev_reset_htab when something has been changed. (rewrite_commutative_reductions_out_of_ssa): Same. * gcc.dg/graphite/id-26.c: New. --- gcc/ChangeLog.graphite | 12 +++++ gcc/graphite-sese-to-poly.c | 75 ++++++++++++++++++++++---------- gcc/testsuite/gcc.dg/graphite/id-26.c | 24 ++++++++++ 3 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/graphite/id-26.c diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 19ddf88..eccdee1 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,15 @@ +2010-07-27 Sebastian Pop + + * graphite-sese-to-poly.c (rewrite_cross_bb_scalar_deps): Returns + a bool. + (rewrite_commutative_reductions_out_of_ssa_close_phi): Same. + (rewrite_commutative_reductions_out_of_ssa_loop): Same. + (rewrite_cross_bb_scalar_deps_out_of_ssa): Call scev_reset_htab + when something has been changed. + (rewrite_commutative_reductions_out_of_ssa): Same. + + * gcc.dg/graphite/id-26.c: New. + 2010-07-26 Sebastian Pop * graphite-sese-to-poly.c (propagate_expr_outside_region): Also diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 2fc3ccf..1576952 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -2427,9 +2427,10 @@ rewrite_cross_bb_scalar_dependence (tree zero_dim_array, tree def, gimple use_st } /* Rewrite the scalar dependences crossing the boundary of the BB - containing STMT with an array. */ + containing STMT with an array. Return true when something has been + changed. */ -static void +static bool rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi) { gimple stmt = gsi_stmt (*gsi); @@ -2438,6 +2439,7 @@ rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi) basic_block def_bb; tree zero_dim_array = NULL_TREE; gimple use_stmt; + bool res = false; switch (gimple_code (stmt)) { @@ -2450,27 +2452,29 @@ rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi) break; default: - return; + return false; } if (!is_gimple_reg (def)) - return; + return false; if (scev_analyzable_p (def, region)) { loop_p loop = loop_containing_stmt (SSA_NAME_DEF_STMT (def)); tree scev = scalar_evolution_in_region (region, loop, def); - if (tree_does_not_contain_chrecs (scev)) - propagate_expr_outside_region (def, scev, region); + if (tree_contains_chrecs (scev, NULL)) + return false; - return; + propagate_expr_outside_region (def, scev, region); + return true; } def_bb = gimple_bb (stmt); FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) - if (gimple_code (use_stmt) == GIMPLE_PHI) + if (gimple_code (use_stmt) == GIMPLE_PHI + && (res = true)) { gimple_stmt_iterator psi = gsi_for_stmt (use_stmt); @@ -2483,7 +2487,8 @@ rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi) FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) if (gimple_code (use_stmt) != GIMPLE_PHI && def_bb != gimple_bb (use_stmt) - && !is_gimple_debug (use_stmt)) + && !is_gimple_debug (use_stmt) + && (res = true)) { if (!zero_dim_array) { @@ -2496,6 +2501,8 @@ rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi) rewrite_cross_bb_scalar_dependence (zero_dim_array, def, use_stmt); } + + return res; } /* Rewrite out of SSA all the reduction phi nodes of SCOP. */ @@ -2506,16 +2513,21 @@ rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop) basic_block bb; gimple_stmt_iterator psi; sese region = SCOP_REGION (scop); + bool changed = false; FOR_EACH_BB (bb) if (bb_in_sese_p (bb, region)) for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi)) - rewrite_cross_bb_scalar_deps (region, &psi); + changed |= rewrite_cross_bb_scalar_deps (region, &psi); - update_ssa (TODO_update_ssa); + if (changed) + { + scev_reset_htab (); + update_ssa (TODO_update_ssa); #ifdef ENABLE_CHECKING - verify_loop_closed_ssa (true); + verify_loop_closed_ssa (true); #endif + } } /* Returns the number of pbbs that are in loops contained in SCOP. */ @@ -2901,26 +2913,31 @@ translate_scalar_reduction_to_array (VEC (gimple, heap) *in, } } -/* Rewrites out of SSA a commutative reduction at CLOSE_PHI. */ +/* Rewrites out of SSA a commutative reduction at CLOSE_PHI. Returns + true when something has been changed. */ -static void +static bool rewrite_commutative_reductions_out_of_ssa_close_phi (gimple close_phi, sbitmap reductions) { + bool res; VEC (gimple, heap) *in = VEC_alloc (gimple, heap, 10); VEC (gimple, heap) *out = VEC_alloc (gimple, heap, 10); detect_commutative_reduction (close_phi, &in, &out); - if (VEC_length (gimple, in) > 0) + res = VEC_length (gimple, in) > 0; + if (res) translate_scalar_reduction_to_array (in, out, reductions); VEC_free (gimple, heap, in); VEC_free (gimple, heap, out); + return res; } -/* Rewrites all the commutative reductions from LOOP out of SSA. */ +/* Rewrites all the commutative reductions from LOOP out of SSA. + Returns true when something has been changed. */ -static void +static bool rewrite_commutative_reductions_out_of_ssa_loop (loop_p loop, sbitmap reductions, sese region) @@ -2928,16 +2945,19 @@ rewrite_commutative_reductions_out_of_ssa_loop (loop_p loop, gimple_stmt_iterator gsi; edge exit = single_exit (loop); tree res; + bool changed = false; if (!exit) - return; + return false; for (gsi = gsi_start_phis (exit->dest); !gsi_end_p (gsi); gsi_next (&gsi)) if ((res = gimple_phi_result (gsi_stmt (gsi))) && is_gimple_reg (res) && !scev_analyzable_p (res, region)) - rewrite_commutative_reductions_out_of_ssa_close_phi (gsi_stmt (gsi), - reductions); + changed |= rewrite_commutative_reductions_out_of_ssa_close_phi + (gsi_stmt (gsi), reductions); + + return changed; } /* Rewrites all the commutative reductions from SCOP out of SSA. */ @@ -2947,19 +2967,26 @@ rewrite_commutative_reductions_out_of_ssa (sese region, sbitmap reductions) { loop_iterator li; loop_p loop; + bool changed = false; if (!flag_associative_math) return; FOR_EACH_LOOP (li, loop, 0) if (loop_in_sese_p (loop, region)) - rewrite_commutative_reductions_out_of_ssa_loop (loop, reductions, region); + changed |= rewrite_commutative_reductions_out_of_ssa_loop (loop, + reductions, + region); - gsi_commit_edge_inserts (); - update_ssa (TODO_update_ssa); + if (changed) + { + scev_reset_htab (); + gsi_commit_edge_inserts (); + update_ssa (TODO_update_ssa); #ifdef ENABLE_CHECKING - verify_loop_closed_ssa (true); + verify_loop_closed_ssa (true); #endif + } } /* Java does not initialize long_long_integer_type_node. */ diff --git a/gcc/testsuite/gcc.dg/graphite/id-26.c b/gcc/testsuite/gcc.dg/graphite/id-26.c new file mode 100644 index 0000000..507d159 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-26.c @@ -0,0 +1,24 @@ +int find_sad_16x16(int *intra_mode) +{ + int current_intra_sad_2,best_intra_sad2; + int M1[16][16],M0[4][4][4][4],M3[4],M4[4][4]; + int i,j,k; + int ii,jj; + int up_avail, left_avail, left_up_avail; + for (i=0;i<17;i++) + if (left_up_avail) + { + for (jj=0;jj<4;jj++) + for (ii=0;ii<4;ii++) + for (j=0;j<4;j++) + for (i=0;i<4;i++) + { + M0[i][ii][2][jj]=M3[0]-M3[1]; + M0[i][ii][1][jj]=M3[2]+M3[3]; + current_intra_sad_2 += abs(M0[i][ii][j][jj]); + } + + if(current_intra_sad_2 < best_intra_sad2) + best_intra_sad2=current_intra_sad_2; + } +}