aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-parloops.c
diff options
context:
space:
mode:
authorSebastian Pop <sebastian.pop@amd.com>2009-03-03 03:47:22 +0000
committerSebastian Pop <spop@gcc.gnu.org>2009-03-03 03:47:22 +0000
commit7d4fba4aaca3f36d15a719acb5c74cb7ff3966ec (patch)
treec5940d475af6b9c54d559dc260ef19fbe60c76c9 /gcc/tree-parloops.c
parent10fc64a7a62231a36e4f76ce6eb2e9780e3d8d19 (diff)
downloadgcc-7d4fba4aaca3f36d15a719acb5c74cb7ff3966ec.zip
gcc-7d4fba4aaca3f36d15a719acb5c74cb7ff3966ec.tar.gz
gcc-7d4fba4aaca3f36d15a719acb5c74cb7ff3966ec.tar.bz2
re PR middle-end/39335 (ICE in GCC 4.4 with -O[123] -floop-interchange)
2009-03-02 Sebastian Pop <sebastian.pop@amd.com> PR middle-end/39335 * tree-parloops.c (canonicalize_loop_ivs): Call fold_convert when the type precision of the induction variable should be larger than the type precision of nit. (gen_parallel_loop): Update use of canonicalize_loop_ivs. * graphite.c (graphite_loop_normal_form): Same. * tree-flow.h (canonicalize_loop_ivs): Update declaration. * testsuite/gcc.dg/graphite/pr39335_1.c: New. * testsuite/gcc.dg/graphite/pr39335.c: New. From-SVN: r144564
Diffstat (limited to 'gcc/tree-parloops.c')
-rw-r--r--gcc/tree-parloops.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index f1d7227..f2d0ff6 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -1321,16 +1321,20 @@ create_loop_fn (void)
return decl;
}
-/* Bases all the induction variables in LOOP on a single induction variable
- (unsigned with base 0 and step 1), whose final value is compared with
- NIT. The induction variable is incremented in the loop latch.
- REDUCTION_LIST describes the reductions in LOOP. Return the induction
- variable that was created. */
+/* Bases all the induction variables in LOOP on a single induction
+ variable (unsigned with base 0 and step 1), whose final value is
+ compared with *NIT. When the IV type precision has to be larger
+ than *NIT type precision, *NIT is converted to the larger type, the
+ conversion code is inserted before the loop, and *NIT is updated to
+ the new definition. The induction variable is incremented in the
+ loop latch. REDUCTION_LIST describes the reductions in LOOP.
+ Return the induction variable that was created. */
tree
-canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
+canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree *nit)
{
- unsigned precision = TYPE_PRECISION (TREE_TYPE (nit));
+ unsigned precision = TYPE_PRECISION (TREE_TYPE (*nit));
+ unsigned original_precision = precision;
tree res, type, var_before, val, atype, mtype;
gimple_stmt_iterator gsi, psi;
gimple phi, stmt;
@@ -1338,6 +1342,7 @@ canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
affine_iv iv;
edge exit = single_dom_exit (loop);
struct reduction_info *red;
+ gimple_seq stmts;
for (psi = gsi_start_phis (loop->header);
!gsi_end_p (psi); gsi_next (&psi))
@@ -1351,6 +1356,14 @@ canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
type = lang_hooks.types.type_for_size (precision, 1);
+ if (original_precision != precision)
+ {
+ *nit = fold_convert (type, *nit);
+ *nit = force_gimple_operand (*nit, &stmts, true, NULL_TREE);
+ if (stmts)
+ gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
+ }
+
gsi = gsi_last_bb (loop->latch);
create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE,
loop, &gsi, true, &var_before, NULL);
@@ -1410,7 +1423,7 @@ canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
}
gimple_cond_set_code (stmt, LT_EXPR);
gimple_cond_set_lhs (stmt, var_before);
- gimple_cond_set_rhs (stmt, nit);
+ gimple_cond_set_rhs (stmt, *nit);
update_stmt (stmt);
return var_before;
@@ -1760,7 +1773,7 @@ gen_parallel_loop (struct loop *loop, htab_t reduction_list,
free_original_copy_tables ();
/* Base all the induction variables in LOOP on a single control one. */
- canonicalize_loop_ivs (loop, reduction_list, nit);
+ canonicalize_loop_ivs (loop, reduction_list, &nit);
/* Ensure that the exit condition is the first statement in the loop. */
transform_to_exit_first_loop (loop, reduction_list, nit);