re PR tree-optimization/42681 (ICE: in build2_stat, at tree.c:3664 with "-O1 -fgraphite-identity")

Fix PR42681.

2010-01-14  Sebastian Pop  <sebastian.pop@amd.com>

	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
This commit is contained in:
Sebastian Pop 2010-01-14 08:37:26 +00:00 committed by Sebastian Pop
parent cd481d83ed
commit 3c7c015805
5 changed files with 76 additions and 3 deletions

View File

@ -1,3 +1,18 @@
2010-01-14 Sebastian Pop <sebastian.pop@amd.com>
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 <sebastian.pop@amd.com>
PR middle-end/42732

View File

@ -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

View File

@ -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. */

View File

@ -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)

View File

@ -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;
}
}