Commit 06cd4e1b by Mikael Morin

trans-array.c (gfc_trans_create_temp_array): Loop over the parents.

	* trans-array.c (gfc_trans_create_temp_array): Loop over the parents.

From-SVN: r180895
parent d6b3a0d7
2011-11-03 Mikael Morin <mikael@gcc.gnu.org> 2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans-array.c (gfc_trans_create_temp_array): Loop over the parents.
2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans-array.c (get_array_ref_dim, get_scalarizer_dim_for_array_dim): * trans-array.c (get_array_ref_dim, get_scalarizer_dim_for_array_dim):
Rename the former to the latter and loop over the parents. Rename the former to the latter and loop over the parents.
(innermost_ss): New function. (innermost_ss): New function.
......
...@@ -943,6 +943,7 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, ...@@ -943,6 +943,7 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
bool dealloc, bool callee_alloc, locus * where) bool dealloc, bool callee_alloc, locus * where)
{ {
gfc_loopinfo *loop; gfc_loopinfo *loop;
gfc_ss *s;
gfc_array_info *info; gfc_array_info *info;
tree from[GFC_MAX_DIMENSIONS], to[GFC_MAX_DIMENSIONS]; tree from[GFC_MAX_DIMENSIONS], to[GFC_MAX_DIMENSIONS];
tree type; tree type;
...@@ -966,41 +967,45 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, ...@@ -966,41 +967,45 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
if (gfc_option.warn_array_temp && where) if (gfc_option.warn_array_temp && where)
gfc_warning ("Creating array temporary at %L", where); gfc_warning ("Creating array temporary at %L", where);
loop = ss->loop;
total_dim = loop->dimen;
/* Set the lower bound to zero. */ /* Set the lower bound to zero. */
for (n = 0; n < loop->dimen; n++) for (s = ss; s; s = s->parent)
{ {
dim = ss->dim[n]; loop = s->loop;
total_dim += loop->dimen;
for (n = 0; n < loop->dimen; n++)
{
dim = s->dim[n];
/* Callee allocated arrays may not have a known bound yet. */ /* Callee allocated arrays may not have a known bound yet. */
if (loop->to[n]) if (loop->to[n])
loop->to[n] = gfc_evaluate_now ( loop->to[n] = gfc_evaluate_now (
fold_build2_loc (input_location, MINUS_EXPR, fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type, gfc_array_index_type,
loop->to[n], loop->from[n]), loop->to[n], loop->from[n]),
pre); pre);
loop->from[n] = gfc_index_zero_node; loop->from[n] = gfc_index_zero_node;
/* We have just changed the loop bounds, we must clear the /* We have just changed the loop bounds, we must clear the
corresponding specloop, so that delta calculation is not skipped corresponding specloop, so that delta calculation is not skipped
later in set_delta. */ later in set_delta. */
loop->specloop[n] = NULL; loop->specloop[n] = NULL;
/* We are constructing the temporary's descriptor based on the loop /* We are constructing the temporary's descriptor based on the loop
dimensions. As the dimensions may be accessed in arbitrary order dimensions. As the dimensions may be accessed in arbitrary order
(think of transpose) the size taken from the n'th loop may not map (think of transpose) the size taken from the n'th loop may not map
to the n'th dimension of the array. We need to reconstruct loop infos to the n'th dimension of the array. We need to reconstruct loop
in the right order before using it to set the descriptor infos in the right order before using it to set the descriptor
bounds. */ bounds. */
tmp_dim = get_scalarizer_dim_for_array_dim (ss, dim); tmp_dim = get_scalarizer_dim_for_array_dim (ss, dim);
from[tmp_dim] = loop->from[n]; from[tmp_dim] = loop->from[n];
to[tmp_dim] = loop->to[n]; to[tmp_dim] = loop->to[n];
info->delta[dim] = gfc_index_zero_node; info->delta[dim] = gfc_index_zero_node;
info->start[dim] = gfc_index_zero_node; info->start[dim] = gfc_index_zero_node;
info->end[dim] = gfc_index_zero_node; info->end[dim] = gfc_index_zero_node;
info->stride[dim] = gfc_index_one_node; info->stride[dim] = gfc_index_one_node;
}
} }
/* Initialize the descriptor. */ /* Initialize the descriptor. */
...@@ -1042,8 +1047,8 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, ...@@ -1042,8 +1047,8 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
} }
if (size == NULL_TREE) if (size == NULL_TREE)
{ for (s = ss; s; s = s->parent)
for (n = 0; n < loop->dimen; n++) for (n = 0; n < s->loop->dimen; n++)
{ {
dim = get_scalarizer_dim_for_array_dim (ss, ss->dim[n]); dim = get_scalarizer_dim_for_array_dim (ss, ss->dim[n]);
...@@ -1053,9 +1058,8 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, ...@@ -1053,9 +1058,8 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
MINUS_EXPR, gfc_array_index_type, MINUS_EXPR, gfc_array_index_type,
gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]), gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]),
gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim])); gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim]));
loop->to[n] = tmp; s->loop->to[n] = tmp;
} }
}
else else
{ {
for (n = 0; n < total_dim; n++) for (n = 0; n < total_dim; n++)
...@@ -1112,6 +1116,9 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, ...@@ -1112,6 +1116,9 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss,
gfc_trans_allocate_array_storage (pre, post, info, size, nelem, initial, gfc_trans_allocate_array_storage (pre, post, info, size, nelem, initial,
dynamic, dealloc); dynamic, dealloc);
while (ss->parent)
ss = ss->parent;
if (ss->dimen > ss->loop->temp_dim) if (ss->dimen > ss->loop->temp_dim)
ss->loop->temp_dim = ss->dimen; ss->loop->temp_dim = ss->dimen;
......
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