summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-14 07:38:15 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-14 07:38:15 +0000
commitefe339e3ce830410f033049845a704a8487820ef (patch)
treee7d4749d1d7087c6a71839b545d5d0b794c4ca4d /gcc
parent1b374b02c41312743c59418b074020558727bc73 (diff)
downloadgcc-efe339e3ce830410f033049845a704a8487820ef.tar.gz
Fix PR42732.
2010-01-14 Sebastian Pop <sebastian.pop@amd.com> PR middle-end/42732 * graphite-clast-to-gimple.c (gloog): Call scev_reset_htab and rename_nb_iterations. * sese.c (rename_variables_in_operand): New. (rename_variables_in_expr): New. (rename_nb_iterations): New. (sese_adjust_liveout_phis): Update the rename_map. * sese.h (rename_nb_iterations): Declared. * tree-scalar-evolution.c (scev_reset_htab): New. (scev_reset): Call scev_reset_htab. * tree-scalar-evolution.h (scev_reset_htab): Declared. * testsuite/gfortran.dg/graphite/pr42732.f: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155881 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog.graphite16
-rw-r--r--gcc/graphite-clast-to-gimple.c6
-rw-r--r--gcc/sese.c69
-rw-r--r--gcc/sese.h1
-rw-r--r--gcc/testsuite/gfortran.dg/graphite/pr42732.f23
-rw-r--r--gcc/tree-scalar-evolution.c20
-rw-r--r--gcc/tree-scalar-evolution.h1
7 files changed, 128 insertions, 8 deletions
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 9ea58261e22..fe3598cdf3f 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,19 @@
+2010-01-14 Sebastian Pop <sebastian.pop@amd.com>
+
+ PR middle-end/42732
+ * graphite-clast-to-gimple.c (gloog): Call scev_reset_htab and
+ rename_nb_iterations.
+ * sese.c (rename_variables_in_operand): New.
+ (rename_variables_in_expr): New.
+ (rename_nb_iterations): New.
+ (sese_adjust_liveout_phis): Update the rename_map.
+ * sese.h (rename_nb_iterations): Declared.
+ * tree-scalar-evolution.c (scev_reset_htab): New.
+ (scev_reset): Call scev_reset_htab.
+ * tree-scalar-evolution.h (scev_reset_htab): Declared.
+
+ * testsuite/gfortran.dg/graphite/pr42732.f: New.
+
2010-01-08 Sebastian Pop <sebastian.pop@amd.com>
PR middle-end/42393
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index bbc77d21a48..be16807872c 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -1400,8 +1400,8 @@ debug_generated_program (scop_p scop)
print_generated_program (stderr, scop);
}
-/* Add CLooG names to parameter index. The index is used to translate back from
- * CLooG names to GCC trees. */
+/* Add CLooG names to parameter index. The index is used to translate
+ back from CLooG names to GCC trees. */
static void
create_params_index (htab_t index_table, CloogProgram *prog) {
@@ -1471,6 +1471,8 @@ gloog (scop_p scop, htab_t bb_pbb_mapping)
if_region->region->exit->src,
if_region->false_region->exit,
if_region->true_region->exit);
+ scev_reset_htab ();
+ rename_nb_iterations (rename_map);
recompute_all_dominators ();
graphite_verify ();
diff --git a/gcc/sese.c b/gcc/sese.c
index 50ac698ec0f..1c4686de3a2 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -486,7 +486,7 @@ sese_adjust_vphi (sese region, gimple phi, edge true_e)
}
}
-/* Returns the name associated to OLD_NAME in MAP. */
+/* Returns the expression associated to OLD_NAME in MAP. */
static tree
get_rename (htab_t map, tree old_name)
@@ -503,7 +503,7 @@ get_rename (htab_t map, tree old_name)
return old_name;
}
-/* Register in MAP the rename tuple (old_name, expr). */
+/* Register in MAP the rename tuple (OLD_NAME, EXPR). */
void
set_rename (htab_t map, tree old_name, tree expr)
@@ -526,6 +526,67 @@ set_rename (htab_t map, tree old_name, tree 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
+ RENAME_MAP. */
+
+static void
+rename_variables_in_expr (htab_t rename_map, tree t)
+{
+ if (!t)
+ return;
+
+ switch (TREE_CODE_LENGTH (TREE_CODE (t)))
+ {
+ case 3:
+ rename_variables_in_operand (rename_map, t, 2);
+
+ case 2:
+ rename_variables_in_operand (rename_map, t, 1);
+
+ case 1:
+ rename_variables_in_operand (rename_map, t, 0);
+
+ default:
+ return;
+ }
+}
+
+/* Renames all the loop->nb_iterations expressions following the
+ tuples (OLD_NAME, EXPR) in RENAME_MAP. */
+
+void
+rename_nb_iterations (htab_t rename_map)
+{
+ loop_iterator li;
+ struct loop *loop;
+
+ FOR_EACH_LOOP (li, loop, 0)
+ {
+ rename_variables_in_expr (rename_map, loop->nb_iterations);
+ }
+}
+
/* Adjusts the phi nodes in the block BB for variables defined in
SCOP_REGION and used outside the SCOP_REGION. The code generation
moves SCOP_REGION in the else clause of an "if (1)" and generates
@@ -550,8 +611,9 @@ sese_adjust_liveout_phis (sese region, htab_t rename_map, basic_block bb,
unsigned i;
unsigned false_i = 0;
gimple phi = gsi_stmt (si);
+ tree res = gimple_phi_result (phi);
- if (!is_gimple_reg (PHI_RESULT (phi)))
+ if (!is_gimple_reg (res))
{
sese_adjust_vphi (region, phi, true_e);
continue;
@@ -585,6 +647,7 @@ sese_adjust_liveout_phis (sese region, htab_t rename_map, basic_block bb,
}
SET_PHI_ARG_DEF (phi, i, expr);
+ set_rename (rename_map, old_name, res);
}
}
}
diff --git a/gcc/sese.h b/gcc/sese.h
index 6763db34c27..350ae48241e 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -262,6 +262,7 @@ extern void debug_rename_map (htab_t);
extern hashval_t rename_map_elt_info (const void *);
extern int eq_rename_map_elts (const void *, const void *);
extern void set_rename (htab_t, tree, tree);
+extern void rename_nb_iterations (htab_t);
/* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW. */
diff --git a/gcc/testsuite/gfortran.dg/graphite/pr42732.f b/gcc/testsuite/gfortran.dg/graphite/pr42732.f
new file mode 100644
index 00000000000..95c115076a9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/graphite/pr42732.f
@@ -0,0 +1,23 @@
+! { dg-options "-O2 -fgraphite-identity" }
+
+ parameter(in = 128+5
+ & , jn = 128+5
+ & , kn = 128+5)
+ real*8 d (in,jn,kn)
+ real*8 dcopy(in,jn,kn)
+ call pdv (is, dcopy)
+ do k=ks,ke
+ do j=je+1,je+2
+ do i=is-2,ie+2
+ dcopy(i,j,k) = d(i,j,k)
+ enddo
+ enddo
+ enddo
+ do k=ks,ke
+ do j=js,je
+ do i=is-2,is-1
+ dcopy(i,j,k) = d(i,j,k)
+ enddo
+ enddo
+ enddo
+ end
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 3ebc54e8556..4d8f85e5047 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -3033,7 +3033,20 @@ scev_initialize (void)
}
}
-/* Cleans up the information cached by the scalar evolutions analysis. */
+/* Cleans up the information cached by the scalar evolutions analysis
+ in the hash table. */
+
+void
+scev_reset_htab (void)
+{
+ if (!scalar_evolution_info)
+ return;
+
+ htab_empty (scalar_evolution_info);
+}
+
+/* Cleans up the information cached by the scalar evolutions analysis
+ in the hash table and in the loop->nb_iterations. */
void
scev_reset (void)
@@ -3041,10 +3054,11 @@ scev_reset (void)
loop_iterator li;
struct loop *loop;
- if (!scalar_evolution_info || !current_loops)
+ scev_reset_htab ();
+
+ if (!current_loops)
return;
- htab_empty (scalar_evolution_info);
FOR_EACH_LOOP (li, loop, 0)
{
loop->nb_iterations = NULL_TREE;
diff --git a/gcc/tree-scalar-evolution.h b/gcc/tree-scalar-evolution.h
index 5caadc57031..e09e19ae5f5 100644
--- a/gcc/tree-scalar-evolution.h
+++ b/gcc/tree-scalar-evolution.h
@@ -27,6 +27,7 @@ extern gimple get_loop_exit_condition (const struct loop *);
extern void scev_initialize (void);
extern void scev_reset (void);
+extern void scev_reset_htab (void);
extern void scev_finalize (void);
extern tree analyze_scalar_evolution (struct loop *, tree);
extern tree instantiate_scev (basic_block, struct loop *, tree);