trans-stmt.c (compute_overall_iter_number): Enhance to precompute the number of interations in unconditional FORALL nests...

* trans-stmt.c (compute_overall_iter_number): Enhance to precompute
	the number of interations in unconditional FORALL nests with constant
	bounds.

From-SVN: r120905
This commit is contained in:
Roger Sayle 2007-01-18 18:17:08 +00:00 committed by Roger Sayle
parent e2265be077
commit 3bf783b7e2
2 changed files with 33 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2007-01-18 Roger Sayle <roger@eyesopen.com>
* trans-stmt.c (compute_overall_iter_number): Enhance to precompute
the number of interations in unconditional FORALL nests with constant
bounds.
2007-01-18 Francois-Xavier Coudert <coudert@clipper.ens.fr>
Tobias Burnus <burnus@net-b.de>

View File

@ -2034,9 +2034,33 @@ compute_overall_iter_number (forall_info *nested_forall_info, tree inner_size,
tree tmp, number;
stmtblock_t body;
/* Optimize the case for an outer-most loop with constant bounds. */
if (INTEGER_CST_P (inner_size) && !nested_forall_info)
return inner_size;
/* Optimize the case of unconditional FORALL nests with constant bounds. */
if (INTEGER_CST_P (inner_size))
{
bool all_const_p = true;
forall_info *forall_tmp;
/* First check whether all the bounds are constant. */
for (forall_tmp = nested_forall_info;
forall_tmp;
forall_tmp = forall_tmp->next_nest)
if (forall_tmp->mask || !INTEGER_CST_P (forall_tmp->size))
{
all_const_p = false;
break;
}
if (all_const_p)
{
tree tmp = inner_size;
for (forall_tmp = nested_forall_info;
forall_tmp;
forall_tmp = forall_tmp->next_nest)
tmp = fold_build2 (MULT_EXPR, gfc_array_index_type,
tmp, forall->size);
return tmp;
}
}
/* TODO: optimizing the computing process. */
number = gfc_create_var (gfc_array_index_type, "num");