aboutsummaryrefslogtreecommitdiff
path: root/gcc/sese.c
diff options
context:
space:
mode:
authorSebastian Pop <sebastian.pop@amd.com>2010-01-14 07:38:15 +0000
committerSebastian Pop <spop@gcc.gnu.org>2010-01-14 07:38:15 +0000
commita7bf45dee541cfa10350a814f5fbf14c5a316a7f (patch)
treee7d4749d1d7087c6a71839b545d5d0b794c4ca4d /gcc/sese.c
parent453897b4dde0964a55d4b3ebbdbb2bfaabec748a (diff)
downloadgcc-a7bf45dee541cfa10350a814f5fbf14c5a316a7f.zip
gcc-a7bf45dee541cfa10350a814f5fbf14c5a316a7f.tar.gz
gcc-a7bf45dee541cfa10350a814f5fbf14c5a316a7f.tar.bz2
re PR tree-optimization/42732 ([graphite] ICE: verify_ssa failed)
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. From-SVN: r155881
Diffstat (limited to 'gcc/sese.c')
-rw-r--r--gcc/sese.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/gcc/sese.c b/gcc/sese.c
index 50ac698..1c4686d 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);
}
}
}