From patchwork Tue Jul 26 17:50:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 106900 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 7CA35B6F7F for ; Wed, 27 Jul 2011 03:51:05 +1000 (EST) Received: (qmail 23782 invoked by alias); 26 Jul 2011 17:51:02 -0000 Received: (qmail 23763 invoked by uid 22791); 26 Jul 2011 17:50:59 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-qy0-f182.google.com (HELO mail-qy0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Jul 2011 17:50:45 +0000 Received: by qyk38 with SMTP id 38so423451qyk.20 for ; Tue, 26 Jul 2011 10:50:44 -0700 (PDT) Received: by 10.229.2.164 with SMTP id 36mr4565909qcj.279.1311702644154; Tue, 26 Jul 2011 10:50:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.187.79 with HTTP; Tue, 26 Jul 2011 10:50:04 -0700 (PDT) In-Reply-To: References: <1311482408-22717-1-git-send-email-sebpop@gmail.com> From: Sebastian Pop Date: Tue, 26 Jul 2011 12:50:04 -0500 Message-ID: Subject: Re: [PATCH] Fix PR47691: always run scev_const_prop before graphite To: Richard Guenther Cc: gcc-patches@gcc.gnu.org, tobias@grosser.es 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 On Tue, Jul 26, 2011 at 10:56, Sebastian Pop wrote: > On Tue, Jul 26, 2011 at 10:43, Richard Guenther wrote: >> Please make graphite more robust instead. > > Ok, in this case, what about setting gloog_error and stopping the code > generation instead of failing on this gcc_assert. > Here is the patch. Ok for trunk after regstrap? Thanks, Sebastian From 844201ee77000c40e7f842d066715217d3a95eac Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Sat, 23 Jul 2011 23:29:30 -0500 Subject: [PATCH] Fix PR47691: do not abort compilation when code generation fails 2011-07-23 Sebastian Pop PR middle-end/47691 * graphite-clast-to-gimple.c (translate_clast_user): Update use of copy_bb_and_scalar_dependences. * sese.c (rename_uses): Do not call gcc_assert. Set gloog_error. (graphite_copy_stmts_from_block): Update call to rename_uses. (copy_bb_and_scalar_dependences): Update call to graphite_copy_stmts_from_block. * sese.h (copy_bb_and_scalar_dependences): Update declaration. * gfortran.dg/graphite/id-pr47691.f: New. --- gcc/ChangeLog | 11 ++++++ gcc/graphite-clast-to-gimple.c | 2 +- gcc/sese.c | 41 ++++++++++++++++------ gcc/sese.h | 2 +- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gfortran.dg/graphite/id-pr47691.f | 7 ++++ 6 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/graphite/id-pr47691.f diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f3de4df..4c49a62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,16 @@ 2011-07-23 Sebastian Pop + PR middle-end/47691 + * graphite-clast-to-gimple.c (translate_clast_user): Update use of + copy_bb_and_scalar_dependences. + * sese.c (rename_uses): Do not call gcc_assert. Set gloog_error. + (graphite_copy_stmts_from_block): Update call to rename_uses. + (copy_bb_and_scalar_dependences): Update call to + graphite_copy_stmts_from_block. + * sese.h (copy_bb_and_scalar_dependences): Update declaration. + +2011-07-23 Sebastian Pop + PR middle-end/47594 * graphite-sese-to-poly.c (scan_tree_for_params_right_scev): Sign extend constants. diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index a4668d3..bbfd847 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -1019,7 +1019,7 @@ translate_clast_user (struct clast_user_stmt *stmt, edge next_e, build_iv_mapping (iv_map, stmt, ip); next_e = copy_bb_and_scalar_dependences (GBB_BB (gbb), ip->region, - next_e, iv_map); + next_e, iv_map, &gloog_error); VEC_free (tree, heap, iv_map); new_bb = next_e->src; diff --git a/gcc/sese.c b/gcc/sese.c index a03cbc9..ec96dfb 100644 --- a/gcc/sese.c +++ b/gcc/sese.c @@ -458,11 +458,13 @@ set_rename (htab_t rename_map, tree old_name, tree expr) substitution map RENAME_MAP, inserting the gimplification code at GSI_TGT, for the translation REGION, with the original copied statement in LOOP, and using the induction variable renaming map - IV_MAP. Returns true when something has been renamed. */ + IV_MAP. Returns true when something has been renamed. GLOOG_ERROR + is set when the code generation cannot continue. */ static bool rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt, - sese region, loop_p loop, VEC (tree, heap) *iv_map) + sese region, loop_p loop, VEC (tree, heap) *iv_map, + bool *gloog_error) { use_operand_p use_p; ssa_op_iter op_iter; @@ -522,7 +524,11 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt, scalar SSA_NAME used in the scop: all the other scalar SSA_NAMEs should have been translated out of SSA using arrays with one element. */ - gcc_assert (!chrec_contains_undetermined (scev)); + if (chrec_contains_undetermined (scev)) + { + *gloog_error = true; + return false; + } new_expr = chrec_apply_map (scev, iv_map); @@ -530,8 +536,12 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt, the uses of the new induction variables. We should be able to use new_expr instead of the old_name in the newly generated loop nest. */ - gcc_assert (!chrec_contains_undetermined (new_expr) - && !tree_contains_chrecs (new_expr, NULL)); + if (chrec_contains_undetermined (new_expr) + || tree_contains_chrecs (new_expr, NULL)) + { + *gloog_error = true; + return false; + } /* Replace the old_name with the new_expr. */ new_expr = force_gimple_operand (unshare_expr (new_expr), &stmts, @@ -555,12 +565,14 @@ rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt, } /* Duplicates the statements of basic block BB into basic block NEW_BB - and compute the new induction variables according to the IV_MAP. */ + and compute the new induction variables according to the IV_MAP. + GLOOG_ERROR is set when the code generation cannot continue. */ static void graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, htab_t rename_map, - VEC (tree, heap) *iv_map, sese region) + VEC (tree, heap) *iv_map, sese region, + bool *gloog_error) { gimple_stmt_iterator gsi, gsi_tgt; loop_p loop = bb->loop_father; @@ -605,27 +617,34 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb, set_rename (rename_map, old_name, new_name); } - if (rename_uses (copy, rename_map, &gsi_tgt, region, loop, iv_map)) + if (rename_uses (copy, rename_map, &gsi_tgt, region, loop, iv_map, + gloog_error)) fold_stmt_inplace (copy); + if (*gloog_error) + break; + update_stmt (copy); } } /* Copies BB and includes in the copied BB all the statements that can be reached following the use-def chains from the memory accesses, - and returns the next edge following this new block. */ + and returns the next edge following this new block. GLOOG_ERROR is + set when the code generation cannot continue. */ edge copy_bb_and_scalar_dependences (basic_block bb, sese region, - edge next_e, VEC (tree, heap) *iv_map) + edge next_e, VEC (tree, heap) *iv_map, + bool *gloog_error) { basic_block new_bb = split_edge (next_e); htab_t rename_map = htab_create (10, rename_map_elt_info, eq_rename_map_elts, free); next_e = single_succ_edge (new_bb); - graphite_copy_stmts_from_block (bb, new_bb, rename_map, iv_map, region); + graphite_copy_stmts_from_block (bb, new_bb, rename_map, iv_map, region, + gloog_error); remove_phi_nodes (new_bb); htab_delete (rename_map); diff --git a/gcc/sese.h b/gcc/sese.h index d3b8958..7c6a9c6 100644 --- a/gcc/sese.h +++ b/gcc/sese.h @@ -57,7 +57,7 @@ extern void free_sese (sese); extern void sese_insert_phis_for_liveouts (sese, basic_block, edge, edge); extern void build_sese_loop_nests (sese); extern edge copy_bb_and_scalar_dependences (basic_block, sese, edge, - VEC (tree, heap) *); + VEC (tree, heap) *, bool *); extern struct loop *outermost_loop_in_sese (sese, basic_block); extern void insert_loop_close_phis (htab_t, loop_p); extern void insert_guard_phis (basic_block, edge, edge, htab_t, htab_t); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5115e60..1dce2bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2011-07-23 Sebastian Pop + PR middle-end/47691 + * gfortran.dg/graphite/id-pr47691.f: New. + +2011-07-23 Sebastian Pop + PR middle-end/47594 * gfortran.dg/graphite/run-id-pr47594.f90: New. diff --git a/gcc/testsuite/gfortran.dg/graphite/id-pr47691.f b/gcc/testsuite/gfortran.dg/graphite/id-pr47691.f new file mode 100644 index 0000000..0abbd55 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/id-pr47691.f @@ -0,0 +1,7 @@ +! { dg-options "-O -fgraphite-identity -ffast-math -fno-tree-scev-cprop" } + dimension b(12,8) + do i=1,norb + end do + b(i,j) = 0 + call rdrsym(b) + end -- 1.7.4.1