aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Morin <mikael@gcc.gnu.org>2024-07-08 09:38:42 +0200
committerMikael Morin <mikael@gcc.gnu.org>2024-07-08 09:38:42 +0200
commit7183a8ca18d5889a1f66ec1edbda00200d700c6c (patch)
treee40a0cb674b4a42b6ee3e9acadd6c2e3c983dcf1
parent682731d11f9c02b24358d1af1e2bf6fca0221ee7 (diff)
downloadgcc-7183a8ca18d5889a1f66ec1edbda00200d700c6c.zip
gcc-7183a8ca18d5889a1f66ec1edbda00200d700c6c.tar.gz
gcc-7183a8ca18d5889a1f66ec1edbda00200d700c6c.tar.bz2
fortran: Move definition of variable closer to its uses
No change of behaviour, this makes a variable easier to track. gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_preloop_setup): Use a separate variable for iteration. Use directly the value of variable I if it is known. Move the definition of the variable to the branch where the remaining uses are.
-rw-r--r--gcc/fortran/trans-array.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 510f429..c7d2446 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -4294,7 +4294,6 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
gfc_ss *ss, *pss;
gfc_loopinfo *ploop;
gfc_array_ref *ar;
- int i;
/* This code will be executed before entering the scalarization loop
for this dimension. */
@@ -4340,19 +4339,12 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
pss = ss;
}
- if (dim == loop->dimen - 1)
- i = 0;
- else
- i = dim + 1;
-
- /* For the time being, there is no loop reordering. */
- gcc_assert (i == ploop->order[i]);
- i = ploop->order[i];
-
if (dim == loop->dimen - 1 && loop->parent == NULL)
{
+ gcc_assert (0 == ploop->order[0]);
+
stride = gfc_conv_array_stride (info->descriptor,
- innermost_ss (ss)->dim[i]);
+ innermost_ss (ss)->dim[0]);
/* Calculate the stride of the innermost loop. Hopefully this will
allow the backend optimizers to do their stuff more effectively.
@@ -4364,7 +4356,7 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
base offset of the array. */
if (info->ref)
{
- for (i = 0; i < ar->dimen; i++)
+ for (int i = 0; i < ar->dimen; i++)
{
if (ar->dimen_type[i] != DIMEN_ELEMENT)
continue;
@@ -4374,8 +4366,21 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
}
}
else
- /* Add the offset for the previous loop dimension. */
- add_array_offset (pblock, ploop, ss, ar, pss->dim[i], i);
+ {
+ int i;
+
+ if (dim == loop->dimen - 1)
+ i = 0;
+ else
+ i = dim + 1;
+
+ /* For the time being, there is no loop reordering. */
+ gcc_assert (i == ploop->order[i]);
+ i = ploop->order[i];
+
+ /* Add the offset for the previous loop dimension. */
+ add_array_offset (pblock, ploop, ss, ar, pss->dim[i], i);
+ }
/* Remember this offset for the second loop. */
if (dim == loop->temp_dim - 1 && loop->parent == NULL)