Commit f03077b0 by Mikael Morin

trans-array.c (constant_array_constructor_loop_size): Handle multiple loops.

	* trans-array.c (constant_array_constructor_loop_size):
	Handle multiple loops.

From-SVN: r180901
parent b2f82aaa
2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans-array.c (constant_array_constructor_loop_size):
Handle multiple loops.
2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans-array.c (get_rank, get_loop_upper_bound_for_array):
New functions.
(gfc_trans_array_constructor): Handle multiple loops.
......
......@@ -2053,12 +2053,17 @@ get_rank (gfc_loopinfo *loop)
iteration count of the loop if suitable, and NULL_TREE otherwise. */
static tree
constant_array_constructor_loop_size (gfc_loopinfo * loop)
constant_array_constructor_loop_size (gfc_loopinfo * l)
{
gfc_loopinfo *loop;
tree size = gfc_index_one_node;
tree tmp;
int i;
int i, total_dim;
total_dim = get_rank (l);
for (loop = l; loop; loop = loop->parent)
{
for (i = 0; i < loop->dimen; i++)
{
/* If the bounds aren't constant, return NULL_TREE. */
......@@ -2067,7 +2072,7 @@ constant_array_constructor_loop_size (gfc_loopinfo * loop)
if (!integer_zerop (loop->from[i]))
{
/* Only allow nonzero "from" in one-dimensional arrays. */
if (loop->dimen != 1)
if (total_dim != 1)
return NULL_TREE;
tmp = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type,
......@@ -2075,10 +2080,11 @@ constant_array_constructor_loop_size (gfc_loopinfo * loop)
}
else
tmp = loop->to[i];
tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
tmp, gfc_index_one_node);
size = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
size, tmp);
tmp = fold_build2_loc (input_location, PLUS_EXPR,
gfc_array_index_type, tmp, gfc_index_one_node);
size = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, size, tmp);
}
}
return size;
......
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