Commit 1fb35a90 by Mikael Morin

trans-array.c (gfc_trans_preloop_setup): Move array reference initialisation earlier.


	* trans-array.c (gfc_trans_preloop_setup): Move array reference
	initialisation earlier. Factor subsequent array references.

From-SVN: r180842
parent 177b1d35
2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans-array.c (gfc_trans_preloop_setup): Move array reference
initialisation earlier. Factor subsequent array references.
2011-11-02 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2011-11-02 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* Makef-lang.in (gfortranspec.o): Pass SHLIB instead of SHLIB_LINK. * Makef-lang.in (gfortranspec.o): Pass SHLIB instead of SHLIB_LINK.
......
...@@ -2842,6 +2842,7 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, ...@@ -2842,6 +2842,7 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
gfc_ss_info *info; gfc_ss_info *info;
gfc_ss *ss; gfc_ss *ss;
gfc_se se; gfc_se se;
gfc_array_ref *ar;
int i; int i;
/* This code will be executed before entering the scalarization loop /* This code will be executed before entering the scalarization loop
...@@ -2861,6 +2862,18 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, ...@@ -2861,6 +2862,18 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
if (dim >= info->dimen) if (dim >= info->dimen)
continue; continue;
if (info->ref)
{
ar = &info->ref->u.ar;
i = loop->order[dim + 1];
}
else
{
ar = NULL;
i = dim + 1;
}
if (dim == info->dimen - 1) if (dim == info->dimen - 1)
{ {
/* For the outermost loop calculate the offset due to any /* For the outermost loop calculate the offset due to any
...@@ -2868,9 +2881,9 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, ...@@ -2868,9 +2881,9 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
base offset of the array. */ base offset of the array. */
if (info->ref) if (info->ref)
{ {
for (i = 0; i < info->ref->u.ar.dimen; i++) for (i = 0; i < ar->dimen; i++)
{ {
if (info->ref->u.ar.dimen_type[i] != DIMEN_ELEMENT) if (ar->dimen_type[i] != DIMEN_ELEMENT)
continue; continue;
gfc_init_se (&se, NULL); gfc_init_se (&se, NULL);
...@@ -2878,8 +2891,7 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, ...@@ -2878,8 +2891,7 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
se.expr = info->descriptor; se.expr = info->descriptor;
stride = gfc_conv_array_stride (info->descriptor, i); stride = gfc_conv_array_stride (info->descriptor, i);
index = gfc_conv_array_index_offset (&se, info, i, -1, index = gfc_conv_array_index_offset (&se, info, i, -1,
&info->ref->u.ar, ar, stride);
stride);
gfc_add_block_to_block (pblock, &se.pre); gfc_add_block_to_block (pblock, &se.pre);
info->offset = fold_build2_loc (input_location, PLUS_EXPR, info->offset = fold_build2_loc (input_location, PLUS_EXPR,
...@@ -2903,19 +2915,6 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, ...@@ -2903,19 +2915,6 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
else else
{ {
/* Add the offset for the previous loop dimension. */ /* Add the offset for the previous loop dimension. */
gfc_array_ref *ar;
if (info->ref)
{
ar = &info->ref->u.ar;
i = loop->order[dim + 1];
}
else
{
ar = NULL;
i = dim + 1;
}
gfc_init_se (&se, NULL); gfc_init_se (&se, NULL);
se.loop = loop; se.loop = loop;
se.expr = info->descriptor; se.expr = info->descriptor;
......
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