From patchwork Fri Jan 21 19:27:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 79901 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 33555B6F10 for ; Sat, 22 Jan 2011 06:31:25 +1100 (EST) Received: (qmail 17687 invoked by alias); 21 Jan 2011 19:30:32 -0000 Received: (qmail 17175 invoked by uid 22791); 21 Jan 2011 19:30:21 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_SV, TW_TM, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gw0-f47.google.com (HELO mail-gw0-f47.google.com) (74.125.83.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Jan 2011 19:30:03 +0000 Received: by gwaa12 with SMTP id a12so670790gwa.20 for ; Fri, 21 Jan 2011 11:30:01 -0800 (PST) Received: by 10.151.42.3 with SMTP id u3mr1212245ybj.122.1295638201275; Fri, 21 Jan 2011 11:30:01 -0800 (PST) Received: from napoca ([76.233.39.4]) by mx.google.com with ESMTPS id k1sm6323207ybj.0.2011.01.21.11.29.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 21 Jan 2011 11:30:00 -0800 (PST) Received: by napoca (sSMTP sendmail emulation); Fri, 21 Jan 2011 13:29:58 -0600 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de Subject: [PATCH 16/28] Remove the temporary array for reductions written to memory. Date: Fri, 21 Jan 2011 13:27:35 -0600 Message-Id: <1295638067-13460-17-git-send-email-sebpop@gmail.com> In-Reply-To: References: 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 From: spop 2011-01-15 Sebastian Pop * graphite-sese-to-poly.c (translate_scalar_reduction_to_array_for_stmt): Call unshare_expr. (close_phi_written_to_memory): New. (translate_scalar_reduction_to_array): Call close_phi_written_to_memory and unshare_expr. * gcc.dg/graphite/block-0.c: Un-XFAILed. * gcc.dg/graphite/block-1.c: Un-XFAILed. * gcc.dg/graphite/block-7.c: Un-XFAILed. * gcc.dg/graphite/block-8.c: Un-XFAILed. * gcc.dg/graphite/interchange-12.c: Un-XFAILed. * gcc.dg/graphite/interchange-14.c: Un-XFAILed. * gcc.dg/graphite/interchange-15.c: Un-XFAILed. * gcc.dg/graphite/interchange-8.c: Un-XFAILed. * gcc.dg/graphite/interchange-mvt.c: Un-XFAILed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@168842 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++ gcc/ChangeLog.graphite | 18 +++++++++ gcc/graphite-sese-to-poly.c | 43 ++++++++++++++++++----- gcc/testsuite/ChangeLog | 12 ++++++ gcc/testsuite/gcc.dg/graphite/block-0.c | 4 +- gcc/testsuite/gcc.dg/graphite/block-1.c | 5 ++- gcc/testsuite/gcc.dg/graphite/block-7.c | 2 +- gcc/testsuite/gcc.dg/graphite/block-8.c | 2 +- gcc/testsuite/gcc.dg/graphite/interchange-12.c | 5 +-- gcc/testsuite/gcc.dg/graphite/interchange-14.c | 5 +-- gcc/testsuite/gcc.dg/graphite/interchange-15.c | 2 +- gcc/testsuite/gcc.dg/graphite/interchange-8.c | 5 ++- gcc/testsuite/gcc.dg/graphite/interchange-mvt.c | 2 +- 13 files changed, 89 insertions(+), 24 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c91937e..fecd13f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2011-01-21 Sebastian Pop + * graphite-sese-to-poly.c + (translate_scalar_reduction_to_array_for_stmt): Call unshare_expr. + (close_phi_written_to_memory): New. + (translate_scalar_reduction_to_array): Call close_phi_written_to_memory + and unshare_expr. + +2011-01-21 Sebastian Pop + * graphite-dependences.c: Include graphite-cloog-util.h. (new_poly_ddr): Inlined into dependence_polyhedron. (free_poly_ddr): Moved close by new_poly_ddr. diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 62b5999..3f6ef54 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,23 @@ 2011-01-15 Sebastian Pop + * graphite-sese-to-poly.c + (translate_scalar_reduction_to_array_for_stmt): Call unshare_expr. + (close_phi_written_to_memory): New. + (translate_scalar_reduction_to_array): Call close_phi_written_to_memory + and unshare_expr. + + * gcc.dg/graphite/block-0.c: Un-XFAILed. + * gcc.dg/graphite/block-1.c: Un-XFAILed. + * gcc.dg/graphite/block-7.c: Un-XFAILed. + * gcc.dg/graphite/block-8.c: Un-XFAILed. + * gcc.dg/graphite/interchange-12.c: Un-XFAILed. + * gcc.dg/graphite/interchange-14.c: Un-XFAILed. + * gcc.dg/graphite/interchange-15.c: Un-XFAILed. + * gcc.dg/graphite/interchange-8.c: Un-XFAILed. + * gcc.dg/graphite/interchange-mvt.c: Un-XFAILed. + +2011-01-15 Sebastian Pop + * doc/install.texi: Update the expected version number of PPL to 0.11. * graphite-ppl.c (ppl_powerset_is_empty): Remove now dead code under #if PPL_VERSION_MINOR < 11. diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 1bf2047..301fb96 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -2903,12 +2903,12 @@ translate_scalar_reduction_to_array_for_stmt (scop_p scop, tree red, gimple stmt, gimple loop_phi) { tree res = gimple_phi_result (loop_phi); - gimple assign = gimple_build_assign (res, red); + gimple assign = gimple_build_assign (res, unshare_expr (red)); gimple_stmt_iterator gsi; insert_stmts (scop, assign, NULL, gsi_after_labels (gimple_bb (loop_phi))); - assign = gimple_build_assign (red, gimple_assign_lhs (stmt)); + assign = gimple_build_assign (unshare_expr (red), gimple_assign_lhs (stmt)); gsi = gsi_for_stmt (stmt); gsi_next (&gsi); insert_stmts (scop, assign, NULL, gsi); @@ -2949,6 +2949,29 @@ remove_phi (gimple phi) remove_phi_node (&gsi, false); } +/* When the result of a CLOSE_PHI is written to a memory location, + return a pointer to that memory reference, otherwise return + NULL_TREE. */ + +static tree +close_phi_written_to_memory (gimple close_phi) +{ + imm_use_iterator imm_iter; + tree res, def = gimple_phi_result (close_phi); + use_operand_p use_p; + gimple stmt; + + FOR_EACH_IMM_USE_FAST (use_p, imm_iter, def) + if ((stmt = USE_STMT (use_p)) + && gimple_code (stmt) == GIMPLE_ASSIGN + && (res = gimple_assign_lhs (stmt)) + && (TREE_CODE (res) == ARRAY_REF + || TREE_CODE (res) == MEM_REF)) + return res; + + return NULL_TREE; +} + /* Rewrite out of SSA the reduction described by the loop phi nodes IN, and the close phi nodes OUT. IN and OUT are structured by loop levels like this: @@ -2964,9 +2987,9 @@ translate_scalar_reduction_to_array (scop_p scop, VEC (gimple, heap) *in, VEC (gimple, heap) *out) { - unsigned int i; gimple loop_phi; - tree red = NULL_TREE; + unsigned int i = VEC_length (gimple, out) - 1; + tree red = close_phi_written_to_memory (VEC_index (gimple, out, i)); FOR_EACH_VEC_ELT (gimple, in, i, loop_phi) { @@ -2980,8 +3003,10 @@ translate_scalar_reduction_to_array (scop_p scop, PBB_IS_REDUCTION (pbb) = true; gcc_assert (close_phi == loop_phi); - red = create_zero_dim_array - (gimple_assign_lhs (stmt), "Commutative_Associative_Reduction"); + if (!red) + red = create_zero_dim_array + (gimple_assign_lhs (stmt), "Commutative_Associative_Reduction"); + translate_scalar_reduction_to_array_for_stmt (scop, red, stmt, VEC_index (gimple, in, 1)); continue; @@ -2989,11 +3014,11 @@ translate_scalar_reduction_to_array (scop_p scop, if (i == VEC_length (gimple, in) - 1) { - insert_out_of_ssa_copy (scop, gimple_phi_result (close_phi), red, - close_phi); + insert_out_of_ssa_copy (scop, gimple_phi_result (close_phi), + unshare_expr (red), close_phi); insert_out_of_ssa_copy_on_edge (scop, edge_initial_value_for_loop_phi (loop_phi), - red, initial_value_for_loop_phi (loop_phi)); + unshare_expr (red), initial_value_for_loop_phi (loop_phi)); } remove_phi (loop_phi); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2a6be23..0fe8983 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,17 @@ 2011-01-21 Sebastian Pop + * gcc.dg/graphite/block-0.c: Un-XFAILed. + * gcc.dg/graphite/block-1.c: Un-XFAILed. + * gcc.dg/graphite/block-7.c: Un-XFAILed. + * gcc.dg/graphite/block-8.c: Un-XFAILed. + * gcc.dg/graphite/interchange-12.c: Un-XFAILed. + * gcc.dg/graphite/interchange-14.c: Un-XFAILed. + * gcc.dg/graphite/interchange-15.c: Un-XFAILed. + * gcc.dg/graphite/interchange-8.c: Un-XFAILed. + * gcc.dg/graphite/interchange-mvt.c: Un-XFAILed. + +2011-01-21 Sebastian Pop + * gcc.dg/graphite/block-0.c: Add documentation. * gcc.dg/graphite/block-4.c: Same. * gcc.dg/graphite/block-7.c: Same. diff --git a/gcc/testsuite/gcc.dg/graphite/block-0.c b/gcc/testsuite/gcc.dg/graphite/block-0.c index d772743..9bf9712 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-0.c +++ b/gcc/testsuite/gcc.dg/graphite/block-0.c @@ -12,7 +12,7 @@ foo (void) int j; int i; - /* This should be blocked. */ + /* This is not blocked as it is not profitable. */ for (i = 0; i < N; i++) for (j = 0; j < N; j++) a[j] = a[i] + 1; @@ -42,5 +42,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-not "will be loop blocked" "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-1.c b/gcc/testsuite/gcc.dg/graphite/block-1.c index 876d6f0..d335345 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-1.c +++ b/gcc/testsuite/gcc.dg/graphite/block-1.c @@ -17,6 +17,7 @@ main (void) int A[MAX * MAX]; int B[MAX * MAX]; + /* These loops should be loop blocked. */ for (i = 0; i < MAX; i++) for (j = 0; j < MAX; j++) { @@ -24,10 +25,12 @@ main (void) B[i*MAX + j] = j; } + /* These loops should be loop blocked. */ for (i = 0; i < MAX; i++) for (j = 0; j < MAX; j++) A[i*MAX + j] += B[j*MAX + i]; + /* These loops should be loop blocked. */ for(i = 0; i < MAX; i++) for(j = 0; j < MAX; j++) sum += A[i*MAX + j]; @@ -42,5 +45,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be loop blocked" 2 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "will be loop blocked" 3 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-7.c b/gcc/testsuite/gcc.dg/graphite/block-7.c index 6f33651..fbbe1f3 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-7.c +++ b/gcc/testsuite/gcc.dg/graphite/block-7.c @@ -53,5 +53,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-8.c b/gcc/testsuite/gcc.dg/graphite/block-8.c index 4e7e5b5..9c1c9ce 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-8.c +++ b/gcc/testsuite/gcc.dg/graphite/block-8.c @@ -54,5 +54,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-12.c b/gcc/testsuite/gcc.dg/graphite/interchange-12.c index f569b78..fc27b4c 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-12.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-12.c @@ -14,8 +14,7 @@ matmult (void) { int i, j, k; - /* This should be interchanged twice: (i, k) and (j, i). The - resulting nest should look like this (k, i, j). */ + /* Loops J and K should be interchanged. */ for (i = 0; i < N; i++) for (j = 0; j < N; j++) { @@ -54,5 +53,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-14.c b/gcc/testsuite/gcc.dg/graphite/interchange-14.c index 00b7f82..53809b5 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-14.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-14.c @@ -18,8 +18,7 @@ matmult (void) for (j = 0; j < N; j++) A[i][j] = 0; - /* This should be interchanged twice: (i, k) and (j, i). The - resulting nest should look like this (k, i, j). */ + /* Loops J and K should be interchanged. */ for (i = 0; i < N; i++) for (j = 0; j < N; j++) for (k = 0; k < N; k++) @@ -55,5 +54,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-15.c b/gcc/testsuite/gcc.dg/graphite/interchange-15.c index bfb8a73..9eeef66 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-15.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-15.c @@ -48,6 +48,6 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-8.c b/gcc/testsuite/gcc.dg/graphite/interchange-8.c index e084bd8..ca99dbc 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-8.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-8.c @@ -11,7 +11,8 @@ foo (void) { int i, j, k, l; - /* Loops K and L should be interchanged. */ + /* Loops (L, J) are interchanged, and then loops (J and K) are + interchanged. The result is a nest starting with (K, J, L). */ for (l = 0; l < 4; l++) { for (k = 0; k < 4; k++) @@ -81,5 +82,5 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c index 61e73c1..ee262e9 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c @@ -58,6 +58,6 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */