Commit f28cd38e by Mikael Morin

trans-array.c (gfc_trans_create_temp_array): Move invariant condition out of the containing loop.

	* trans-array.c (gfc_trans_create_temp_array): Move invariant condition
	out of the containing loop.

From-SVN: r180882
parent b2028d0b
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): Move invariant condition
out of the containing loop.
2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans-array.c (gfc_conv_loop_setup, gfc_trans_create_temp_array): * trans-array.c (gfc_conv_loop_setup, gfc_trans_create_temp_array):
Move specloop arrays clearing from the former to the latter. Move specloop arrays clearing from the former to the latter.
......
...@@ -961,12 +961,12 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, ...@@ -961,12 +961,12 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
break; break;
} }
for (n = 0; n < loop->dimen; n++) if (size == NULL_TREE)
{ {
dim = ss->dim[n]; for (n = 0; n < loop->dimen; n++)
if (size == NULL_TREE)
{ {
dim = ss->dim[n];
/* For a callee allocated array express the loop bounds in terms /* For a callee allocated array express the loop bounds in terms
of the descriptor fields. */ of the descriptor fields. */
tmp = fold_build2_loc (input_location, tmp = fold_build2_loc (input_location,
...@@ -974,39 +974,42 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, ...@@ -974,39 +974,42 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
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; loop->to[n] = tmp;
continue;
} }
}
/* Store the stride and bound components in the descriptor. */ else
gfc_conv_descriptor_stride_set (pre, desc, gfc_rank_cst[n], size); {
for (n = 0; n < loop->dimen; n++)
{
/* Store the stride and bound components in the descriptor. */
gfc_conv_descriptor_stride_set (pre, desc, gfc_rank_cst[n], size);
gfc_conv_descriptor_lbound_set (pre, desc, gfc_rank_cst[n], gfc_conv_descriptor_lbound_set (pre, desc, gfc_rank_cst[n],
gfc_index_zero_node); gfc_index_zero_node);
gfc_conv_descriptor_ubound_set (pre, desc, gfc_rank_cst[n], gfc_conv_descriptor_ubound_set (pre, desc, gfc_rank_cst[n], to[n]);
to[n]);
tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, tmp = fold_build2_loc (input_location, PLUS_EXPR,
to[n], gfc_index_one_node); gfc_array_index_type,
to[n], gfc_index_one_node);
/* Check whether the size for this dimension is negative. */ /* Check whether the size for this dimension is negative. */
cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node, tmp, cond = fold_build2_loc (input_location, LE_EXPR, boolean_type_node,
gfc_index_zero_node); tmp, gfc_index_zero_node);
cond = gfc_evaluate_now (cond, pre); cond = gfc_evaluate_now (cond, pre);
if (n == 0) if (n == 0)
or_expr = cond; or_expr = cond;
else else
or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR, or_expr = fold_build2_loc (input_location, TRUTH_OR_EXPR,
boolean_type_node, or_expr, cond); boolean_type_node, or_expr, cond);
size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, size = fold_build2_loc (input_location, MULT_EXPR,
size, tmp); gfc_array_index_type, size, tmp);
size = gfc_evaluate_now (size, pre); size = gfc_evaluate_now (size, pre);
}
} }
/* Get the size of the array. */ /* Get the size of the array. */
if (size && !callee_alloc) if (size && !callee_alloc)
{ {
/* If or_expr is true, then the extent in at least one /* If or_expr is true, then the extent in at least one
......
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