Commit 30ae600f by Mikael Morin

trans-array.c (gfc_add_loop_ss_code): Skip non-nestedmost ss.

	* trans-array.c (gfc_add_loop_ss_code): Skip non-nestedmost ss.
	Call recursively gfc_add_loop_ss_code for all the nested loops.
	(gfc_conv_ss_startstride): Only get the descriptor for the outermost
	ss. Call recursively gfc_conv_ss_startstride for all the nested loops.
	(set_loop_bounds): Call recursively for all the nested loops.
	(set_delta): Ditto.

From-SVN: r180898
parent 9d758043
2011-11-03 Mikael Morin <mikael@gcc.gnu.org> 2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans-array.c (gfc_add_loop_ss_code): Skip non-nestedmost ss.
Call recursively gfc_add_loop_ss_code for all the nested loops.
(gfc_conv_ss_startstride): Only get the descriptor for the outermost
ss. Call recursively gfc_conv_ss_startstride for all the nested loops.
(set_loop_bounds): Call recursively for all the nested loops.
(set_delta): Ditto.
2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans.h (struct gfc_loopinfo): New fields nested and next. * trans.h (struct gfc_loopinfo): New fields nested and next.
* trans-array.c (gfc_add_ss_to_loop): Update list of nested list if * trans-array.c (gfc_add_ss_to_loop): Update list of nested list if
ss has non-null nested_ss field. ss has non-null nested_ss field.
......
...@@ -2295,10 +2295,12 @@ static void ...@@ -2295,10 +2295,12 @@ static void
gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
locus * where) locus * where)
{ {
gfc_loopinfo *nested_loop;
gfc_se se; gfc_se se;
gfc_ss_info *ss_info; gfc_ss_info *ss_info;
gfc_array_info *info; gfc_array_info *info;
gfc_expr *expr; gfc_expr *expr;
bool skip_nested = false;
int n; int n;
/* TODO: This can generate bad code if there are ordering dependencies, /* TODO: This can generate bad code if there are ordering dependencies,
...@@ -2309,6 +2311,10 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, ...@@ -2309,6 +2311,10 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
{ {
gcc_assert (ss); gcc_assert (ss);
/* Cross loop arrays are handled from within the most nested loop. */
if (ss->nested_ss != NULL)
continue;
ss_info = ss->info; ss_info = ss->info;
expr = ss_info->expr; expr = ss_info->expr;
info = &ss_info->data.array; info = &ss_info->data.array;
...@@ -2355,7 +2361,12 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, ...@@ -2355,7 +2361,12 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
/* Add the expressions for scalar and vector subscripts. */ /* Add the expressions for scalar and vector subscripts. */
for (n = 0; n < GFC_MAX_DIMENSIONS; n++) for (n = 0; n < GFC_MAX_DIMENSIONS; n++)
if (info->subscript[n]) if (info->subscript[n])
gfc_add_loop_ss_code (loop, info->subscript[n], true, where); {
gfc_add_loop_ss_code (loop, info->subscript[n], true, where);
/* The recursive call will have taken care of the nested loops.
No need to do it twice. */
skip_nested = true;
}
set_vector_loop_bounds (ss); set_vector_loop_bounds (ss);
break; break;
...@@ -2410,6 +2421,11 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, ...@@ -2410,6 +2421,11 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
gcc_unreachable (); gcc_unreachable ();
} }
} }
if (!skip_nested)
for (nested_loop = loop->nested; nested_loop;
nested_loop = nested_loop->next)
gfc_add_loop_ss_code (nested_loop, nested_loop->ss, subscript, where);
} }
...@@ -3495,8 +3511,10 @@ done: ...@@ -3495,8 +3511,10 @@ done:
switch (ss_info->type) switch (ss_info->type)
{ {
case GFC_SS_SECTION: case GFC_SS_SECTION:
/* Get the descriptor for the array. */ /* Get the descriptor for the array. If it is a cross loops array,
gfc_conv_ss_descriptor (&loop->pre, ss, !loop->array_parameter); we got the descriptor already in the outermost loop. */
if (ss->parent == NULL)
gfc_conv_ss_descriptor (&loop->pre, ss, !loop->array_parameter);
for (n = 0; n < ss->dimen; n++) for (n = 0; n < ss->dimen; n++)
gfc_conv_section_startstride (loop, ss, ss->dim[n]); gfc_conv_section_startstride (loop, ss, ss->dim[n]);
...@@ -3785,6 +3803,9 @@ done: ...@@ -3785,6 +3803,9 @@ done:
tmp = gfc_finish_block (&block); tmp = gfc_finish_block (&block);
gfc_add_expr_to_block (&loop->pre, tmp); gfc_add_expr_to_block (&loop->pre, tmp);
} }
for (loop = loop->nested; loop; loop = loop->next)
gfc_conv_ss_startstride (loop);
} }
/* Return true if both symbols could refer to the same data object. Does /* Return true if both symbols could refer to the same data object. Does
...@@ -4246,6 +4267,9 @@ set_loop_bounds (gfc_loopinfo *loop) ...@@ -4246,6 +4267,9 @@ set_loop_bounds (gfc_loopinfo *loop)
} }
} }
mpz_clear (i); mpz_clear (i);
for (loop = loop->nested; loop; loop = loop->next)
set_loop_bounds (loop);
} }
...@@ -4356,6 +4380,9 @@ set_delta (gfc_loopinfo *loop) ...@@ -4356,6 +4380,9 @@ set_delta (gfc_loopinfo *loop)
} }
} }
} }
for (loop = loop->nested; loop; loop = loop->next)
set_delta (loop);
} }
......
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