From: Sebastian Pop Date: Thu, 14 Jan 2010 08:37:26 +0000 (+0000) Subject: re PR tree-optimization/42681 (ICE: in build2_stat, at tree.c:3664 with "-O1 -fgraphi... X-Git-Tag: releases/gcc-4.5.0~1240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c7c0158052509c4d4a0a7983c7ebf821551443c;p=thirdparty%2Fgcc.git re PR tree-optimization/42681 (ICE: in build2_stat, at tree.c:3664 with "-O1 -fgraphite-identity") Fix PR42681. 2010-01-14 Sebastian Pop PR middle-end/42681 * graphite-clast-to-gimple.c (gloog_error): New static variable. (clast_to_gcc_expression): Do not build MULT_EXPR of POINTER_TYPE_P. Set gloog_error when such an expression failed to be built. (translate_clast): Early return when gloog_error is set. (gloog): Clear gloog_error. When gloog_error is set, call set_ifsese_condition to enable the original code. Return the status of the code generation based on gloog_error. * sese.c (set_ifsese_condition): New. * sese.h (set_ifsese_condition): Declared. * testsuite/g++.dg/graphite/pr42681.C: New. From-SVN: r155884 --- diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index fe3598cdf3fd..c2bb01e07bd7 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,18 @@ +2010-01-14 Sebastian Pop + + PR middle-end/42681 + * graphite-clast-to-gimple.c (gloog_error): New static variable. + (clast_to_gcc_expression): Do not build MULT_EXPR of POINTER_TYPE_P. + Set gloog_error when such an expression failed to be built. + (translate_clast): Early return when gloog_error is set. + (gloog): Clear gloog_error. When gloog_error is set, call + set_ifsese_condition to enable the original code. Return the status + of the code generation based on gloog_error. + * sese.c (set_ifsese_condition): New. + * sese.h (set_ifsese_condition): Declared. + + * testsuite/g++.dg/graphite/pr42681.C: New. + 2010-01-14 Sebastian Pop PR middle-end/42732 diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index be16807872ca..6651e95b48ff 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -52,6 +52,10 @@ along with GCC; see the file COPYING3. If not see #include "graphite-clast-to-gimple.h" #include "graphite-dependences.h" +/* This flag is set when an error occurred during the translation of + CLAST to Gimple. */ +static bool gloog_error; + /* Verifies properties that GRAPHITE should maintain during translation. */ static inline void @@ -294,7 +298,11 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, newivs_index, params_index); tree cst = gmp_cst_to_tree (type, t->val); name = fold_convert (type, name); - return fold_build2 (MULT_EXPR, type, cst, name); + if (!POINTER_TYPE_P (type)) + return fold_build2 (MULT_EXPR, type, cst, name); + + gloog_error = true; + return cst; } } else @@ -944,7 +952,7 @@ translate_clast (sese region, loop_p context_loop, struct clast_stmt *stmt, htab_t newivs_index, htab_t bb_pbb_mapping, int level, htab_t params_index) { - if (!stmt) + if (!stmt || gloog_error) return next_e; if (CLAST_STMT_IS_A (stmt, stmt_root)) @@ -1431,6 +1439,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) cloog_prog_clast pc; timevar_push (TV_GRAPHITE_CODE_GEN); + gloog_error = false; pc = scop_to_clast (scop); @@ -1476,6 +1485,9 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) recompute_all_dominators (); graphite_verify (); + if (gloog_error) + set_ifsese_condition (if_region, integer_zero_node); + free (if_region->true_region); free (if_region->region); free (if_region); @@ -1502,7 +1514,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) num_no_dependency); } - return true; + return !gloog_error; } #endif diff --git a/gcc/sese.c b/gcc/sese.c index 1c4686de3a26..f959bdb269e2 100644 --- a/gcc/sese.c +++ b/gcc/sese.c @@ -1558,6 +1558,34 @@ move_sese_in_condition (sese region) return if_region; } +/* Replaces the condition of the IF_REGION with CONDITION: + | if (CONDITION) + | true_region; + | else + | false_region; +*/ + +void +set_ifsese_condition (ifsese if_region, tree condition) +{ + sese region = if_region->region; + edge entry = region->entry; + basic_block bb = entry->dest; + gimple last = last_stmt (bb); + gimple_stmt_iterator gsi = gsi_last_bb (bb); + gimple cond_stmt; + + gcc_assert (gimple_code (last) == GIMPLE_COND); + + gsi_remove (&gsi, true); + gsi = gsi_last_bb (bb); + condition = force_gimple_operand_gsi (&gsi, condition, true, NULL, + false, GSI_NEW_STMT); + cond_stmt = gimple_build_cond_from_tree (condition, NULL_TREE, NULL_TREE); + gsi = gsi_last_bb (bb); + gsi_insert_after (&gsi, cond_stmt, GSI_NEW_STMT); +} + /* Returns the scalar evolution of T in REGION. Every variable that is not defined in the REGION is considered a parameter. */ diff --git a/gcc/sese.h b/gcc/sese.h index 350ae48241e7..a54854a7610b 100644 --- a/gcc/sese.h +++ b/gcc/sese.h @@ -229,6 +229,7 @@ extern ifsese create_if_region_on_edge (edge, tree); extern ifsese move_sese_in_condition (sese); extern edge get_true_edge_from_guard_bb (basic_block); extern edge get_false_edge_from_guard_bb (basic_block); +extern void set_ifsese_condition (ifsese, tree); static inline edge if_region_entry (ifsese if_region) diff --git a/gcc/testsuite/g++.dg/graphite/pr42681.C b/gcc/testsuite/g++.dg/graphite/pr42681.C new file mode 100644 index 000000000000..4593e1be416e --- /dev/null +++ b/gcc/testsuite/g++.dg/graphite/pr42681.C @@ -0,0 +1,17 @@ +/* { dg-options "-O1 -fgraphite-identity -fno-loop-block -fno-loop-interchange -fno-loop-strip-mine" } */ + +typedef long unsigned int size_t; +inline void* operator new(size_t, void* __p) throw() { return __p; } + +struct A { + int i, j; + A() : i(0) {} +}; + +void Init(A *a) +{ + for (int i = 0; i < 20; i++) { + new (&a[i]) A; + a[i].j = 0; + } +}