Commit a1954f72 by Sebastian Pop Committed by Sebastian Pop

re PR tree-optimization/42771 ([graphite] ICE: in graphite_loop_normal_form, at…

re PR tree-optimization/42771 ([graphite] ICE: in graphite_loop_normal_form, at graphite-sese-to-poly.c (2))

Fix PR42771.

2010-02-10  Sebastian Pop  <seb@napoca>

	PR middle-end/42771
	* graphite-clast-to-gimple.c (gloog): Call rename_sese_parameters.
	* graphite-clast-to-gimple.h (gloog): Update declaration.
	* graphite-poly.c (new_scop): Clear POLY_SCOP_P.
	* graphite-poly.h (struct poly_bb): Add missing comments.
	(struct scop): Add poly_scop_p field.
	(POLY_SCOP_P): New.
	* graphite-sese-to-poly.c (build_poly_scop): Set POLY_SCOP_P.
	* graphite.c (graphite_transform_loops): Build the polyhedral
	representation for each scop before code generation.
	* sese.c (rename_variables_in_operand): Removed.
	(rename_variables_in_expr): Return the renamed expression.
	(rename_sese_parameters): New.
	* sese.h (rename_sese_parameters): Declared.

	* gcc.dg/graphite/pr42771.c: New.

From-SVN: r156711
parent 01e64c3d
2010-02-10 Sebastian Pop <seb@napoca>
PR middle-end/42771
* graphite-clast-to-gimple.c (gloog): Call rename_sese_parameters.
* graphite-clast-to-gimple.h (gloog): Update declaration.
* graphite-poly.c (new_scop): Clear POLY_SCOP_P.
* graphite-poly.h (struct poly_bb): Add missing comments.
(struct scop): Add poly_scop_p field.
(POLY_SCOP_P): New.
* graphite-sese-to-poly.c (build_poly_scop): Set POLY_SCOP_P.
* graphite.c (graphite_transform_loops): Build the polyhedral
representation for each scop before code generation.
* sese.c (rename_variables_in_operand): Removed.
(rename_variables_in_expr): Return the renamed expression.
(rename_sese_parameters): New.
* sese.h (rename_sese_parameters): Declared.
* gcc.dg/graphite/pr42771.c: New.
2010-02-07 Sebastian Pop <sebastian.pop@amd.com> 2010-02-07 Sebastian Pop <sebastian.pop@amd.com>
* gcc.dg/graphite/block-0.c: Call abort for runtime test. Always * gcc.dg/graphite/block-0.c: Call abort for runtime test. Always
......
...@@ -1428,7 +1428,7 @@ create_params_index (htab_t index_table, CloogProgram *prog) { ...@@ -1428,7 +1428,7 @@ create_params_index (htab_t index_table, CloogProgram *prog) {
*/ */
bool bool
gloog (scop_p scop, htab_t bb_pbb_mapping) gloog (scop_p scop, VEC (scop_p, heap) *scops, htab_t bb_pbb_mapping)
{ {
VEC (tree, heap) *newivs = VEC_alloc (tree, heap, 10); VEC (tree, heap) *newivs = VEC_alloc (tree, heap, 10);
loop_p context_loop; loop_p context_loop;
...@@ -1436,6 +1436,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1436,6 +1436,7 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
ifsese if_region = NULL; ifsese if_region = NULL;
htab_t rename_map, newivs_index, params_index; htab_t rename_map, newivs_index, params_index;
cloog_prog_clast pc; cloog_prog_clast pc;
int i;
timevar_push (TV_GRAPHITE_CODE_GEN); timevar_push (TV_GRAPHITE_CODE_GEN);
gloog_error = false; gloog_error = false;
...@@ -1481,6 +1482,10 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ...@@ -1481,6 +1482,10 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
if_region->true_region->exit); if_region->true_region->exit);
scev_reset_htab (); scev_reset_htab ();
rename_nb_iterations (rename_map); rename_nb_iterations (rename_map);
for (i = 0; VEC_iterate (scop_p, scops, i, scop); i++)
rename_sese_parameters (rename_map, SCOP_REGION (scop));
recompute_all_dominators (); recompute_all_dominators ();
graphite_verify (); graphite_verify ();
......
...@@ -36,7 +36,7 @@ typedef struct bb_pbb_def ...@@ -36,7 +36,7 @@ typedef struct bb_pbb_def
poly_bb_p pbb; poly_bb_p pbb;
}bb_pbb_def; }bb_pbb_def;
extern bool gloog (scop_p, htab_t); extern bool gloog (scop_p, VEC (scop_p, heap) *, htab_t);
extern cloog_prog_clast scop_to_clast (scop_p); extern cloog_prog_clast scop_to_clast (scop_p);
extern void debug_clast_stmt (struct clast_stmt *); extern void debug_clast_stmt (struct clast_stmt *);
extern void print_clast_stmt (FILE *, struct clast_stmt *); extern void print_clast_stmt (FILE *, struct clast_stmt *);
......
...@@ -464,6 +464,8 @@ new_scop (void *region) ...@@ -464,6 +464,8 @@ new_scop (void *region)
SCOP_ORIGINAL_SCHEDULE (scop) = NULL; SCOP_ORIGINAL_SCHEDULE (scop) = NULL;
SCOP_TRANSFORMED_SCHEDULE (scop) = NULL; SCOP_TRANSFORMED_SCHEDULE (scop) = NULL;
SCOP_SAVED_SCHEDULE (scop) = NULL; SCOP_SAVED_SCHEDULE (scop) = NULL;
POLY_SCOP_P (scop) = false;
return scop; return scop;
} }
......
...@@ -277,8 +277,10 @@ struct poly_scattering ...@@ -277,8 +277,10 @@ struct poly_scattering
struct poly_bb struct poly_bb
{ {
/* Pointer to a basic block or a statement in the compiler. */
void *black_box; void *black_box;
/* Pointer to the SCOP containing this PBB. */
scop_p scop; scop_p scop;
/* The iteration domain of this bb. /* The iteration domain of this bb.
...@@ -1303,6 +1305,10 @@ struct scop ...@@ -1303,6 +1305,10 @@ struct scop
/* A hashtable of the data dependence relations for the original /* A hashtable of the data dependence relations for the original
scattering. */ scattering. */
htab_t original_pddrs; htab_t original_pddrs;
/* True when the scop has been converted to its polyhedral
representation. */
bool poly_scop_p;
}; };
#define SCOP_BBS(S) (S->bbs) #define SCOP_BBS(S) (S->bbs)
...@@ -1312,6 +1318,7 @@ struct scop ...@@ -1312,6 +1318,7 @@ struct scop
#define SCOP_ORIGINAL_SCHEDULE(S) (S->original_schedule) #define SCOP_ORIGINAL_SCHEDULE(S) (S->original_schedule)
#define SCOP_TRANSFORMED_SCHEDULE(S) (S->transformed_schedule) #define SCOP_TRANSFORMED_SCHEDULE(S) (S->transformed_schedule)
#define SCOP_SAVED_SCHEDULE(S) (S->saved_schedule) #define SCOP_SAVED_SCHEDULE(S) (S->saved_schedule)
#define POLY_SCOP_P(S) (S->poly_scop_p)
extern scop_p new_scop (void *); extern scop_p new_scop (void *);
extern void free_scop (scop_p); extern void free_scop (scop_p);
......
...@@ -2898,6 +2898,7 @@ build_poly_scop (scop_p scop) ...@@ -2898,6 +2898,7 @@ build_poly_scop (scop_p scop)
scop_to_lst (scop); scop_to_lst (scop);
build_scop_scattering (scop); build_scop_scattering (scop);
build_scop_drs (scop); build_scop_drs (scop);
POLY_SCOP_P (scop) = true;
return true; return true;
} }
......
...@@ -268,20 +268,13 @@ graphite_transform_loops (void) ...@@ -268,20 +268,13 @@ graphite_transform_loops (void)
bb_pbb_mapping = htab_create (10, bb_pbb_map_hash, eq_bb_pbb_map, free); bb_pbb_mapping = htab_create (10, bb_pbb_map_hash, eq_bb_pbb_map, free);
for (i = 0; VEC_iterate (scop_p, scops, i, scop); i++) for (i = 0; VEC_iterate (scop_p, scops, i, scop); i++)
{ build_poly_scop (scop);
bool transform_done = false;
if (!build_poly_scop (scop))
continue;
if (apply_poly_transforms (scop)) for (i = 0; VEC_iterate (scop_p, scops, i, scop); i++)
transform_done = gloog (scop, bb_pbb_mapping); if (POLY_SCOP_P (scop)
else && apply_poly_transforms (scop)
check_poly_representation (scop); && gloog (scop, scops, bb_pbb_mapping))
if (transform_done)
need_cfg_cleanup_p = true; need_cfg_cleanup_p = true;
}
htab_delete (bb_pbb_mapping); htab_delete (bb_pbb_mapping);
free_scops (scops); free_scops (scops);
......
...@@ -526,49 +526,31 @@ set_rename (htab_t map, tree old_name, tree expr) ...@@ -526,49 +526,31 @@ set_rename (htab_t map, tree old_name, tree expr)
*slot = new_rename_map_elt (old_name, expr); *slot = new_rename_map_elt (old_name, expr);
} }
static void rename_variables_in_expr (htab_t, tree);
/* Renames the operand OP of expression T following the tuples
(OLD_NAME, EXPR) in RENAME_MAP. */
static void
rename_variables_in_operand (htab_t rename_map, tree t, int op)
{
tree operand = TREE_OPERAND (t, op);
if (TREE_CODE (operand) == SSA_NAME)
{
tree new_name = get_rename (rename_map, operand);
if (new_name != operand)
TREE_OPERAND (t, op) = new_name;
}
else
rename_variables_in_expr (rename_map, operand);
}
/* Renames the expression T following the tuples (OLD_NAME, EXPR) in /* Renames the expression T following the tuples (OLD_NAME, EXPR) in
RENAME_MAP. */ the rename map M. Returns the expression T after renaming. */
static void static tree
rename_variables_in_expr (htab_t rename_map, tree t) rename_variables_in_expr (htab_t m, tree t)
{ {
if (!t) if (!t)
return; return t;
if (TREE_CODE (t) == SSA_NAME)
return get_rename (m, t);
switch (TREE_CODE_LENGTH (TREE_CODE (t))) switch (TREE_CODE_LENGTH (TREE_CODE (t)))
{ {
case 3: case 3:
rename_variables_in_operand (rename_map, t, 2); TREE_OPERAND (t, 2) = rename_variables_in_expr (m, TREE_OPERAND (t, 2));
case 2: case 2:
rename_variables_in_operand (rename_map, t, 1); TREE_OPERAND (t, 1) = rename_variables_in_expr (m, TREE_OPERAND (t, 1));
case 1: case 1:
rename_variables_in_operand (rename_map, t, 0); TREE_OPERAND (t, 0) = rename_variables_in_expr (m, TREE_OPERAND (t, 0));
default: default:
return; return t;
} }
} }
...@@ -582,9 +564,22 @@ rename_nb_iterations (htab_t rename_map) ...@@ -582,9 +564,22 @@ rename_nb_iterations (htab_t rename_map)
struct loop *loop; struct loop *loop;
FOR_EACH_LOOP (li, loop, 0) FOR_EACH_LOOP (li, loop, 0)
{ loop->nb_iterations = rename_variables_in_expr (rename_map,
rename_variables_in_expr (rename_map, loop->nb_iterations); loop->nb_iterations);
} }
/* Renames all the parameters of SESE following the tuples (OLD_NAME,
EXPR) in RENAME_MAP. */
void
rename_sese_parameters (htab_t rename_map, sese region)
{
int i;
tree p;
for (i = 0; VEC_iterate (tree, SESE_PARAMS (region), i, p); i++)
VEC_replace (tree, SESE_PARAMS (region), i,
rename_variables_in_expr (rename_map, p));
} }
/* Adjusts the phi nodes in the block BB for variables defined in /* Adjusts the phi nodes in the block BB for variables defined in
......
...@@ -264,6 +264,7 @@ extern hashval_t rename_map_elt_info (const void *); ...@@ -264,6 +264,7 @@ extern hashval_t rename_map_elt_info (const void *);
extern int eq_rename_map_elts (const void *, const void *); extern int eq_rename_map_elts (const void *, const void *);
extern void set_rename (htab_t, tree, tree); extern void set_rename (htab_t, tree, tree);
extern void rename_nb_iterations (htab_t); extern void rename_nb_iterations (htab_t);
extern void rename_sese_parameters (htab_t, sese);
/* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW. */ /* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW. */
......
/* { dg-options "-O3 -fgraphite-identity" } */
extern int *A;
extern int B[][4];
extern void bar(void);
void foo(int im, int jm, int cond)
{
int i, j;
if (cond) {
for (i = 0; i < 256; i++)
A[i] = 0;
bar();
}
for (i = 0; i < im; i++)
for (j = 1; j < jm; j++)
if (jm != 8 || j != jm >> 1)
B[j][0] ^= B[j-1][0];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment