[gcc(refs/users/mikael/heads/refactor_descriptor_v08)] Déplacement évaluation stride
Mikael Morin
mikael@gcc.gnu.org
Wed Sep 17 13:47:22 GMT 2025
https://gcc.gnu.org/g:7504dbb918a4df501d502887195deee18bd153ec
commit 7504dbb918a4df501d502887195deee18bd153ec
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Tue Sep 16 21:45:07 2025 +0200
Déplacement évaluation stride
Annulation partielle build_array_ref
Diff:
---
gcc/fortran/trans-array.cc | 42 ++++++++++++++++++++++++++++--------------
gcc/fortran/trans.h | 2 +-
2 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 0a10bb30b2ef..016e246f20e3 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3452,18 +3452,35 @@ array_bound_check_elemental (gfc_se * se, gfc_ss * ss, gfc_expr * expr)
}
+static void
+conv_array_index_dim (gfc_array_ref_info *ref_info, tree index, tree stride)
+{
+ /* Multiply by the stride. */
+ if (stride != NULL && !integer_onep (stride))
+ index = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+ index, stride);
+
+ /* Add the offset for this dimension to the stored offset for all other
+ dimensions. */
+ ref_info->index = fold_build2_loc (input_location, PLUS_EXPR,
+ gfc_array_index_type,
+ ref_info->index, index);
+}
+
+
/* Return the offset for an index. Performs bound checking for elemental
dimensions. Single element references are processed separately.
DIM is the array dimension, I is the loop dimension. */
static void
conv_array_index_offset (gfc_se * se, gfc_ss * ss, int dim, int i,
- gfc_array_ref * ar, tree stride)
+ gfc_array_ref * ar)
{
gfc_array_info *info;
tree index;
tree desc;
tree data;
+ tree stride = NULL_TREE;
info = &ss->info->data.array;
@@ -3559,16 +3576,15 @@ conv_array_index_offset (gfc_se * se, gfc_ss * ss, int dim, int i,
gfc_array_index_type, index, info->delta[dim]);
}
- /* Multiply by the stride. */
- if (stride != NULL && !integer_onep (stride))
- index = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
- index, stride);
+ if (stride == NULL_TREE)
+ {
+ if (i == ss->loop->dimen - 1 && ss->loop->parent == NULL)
+ stride = info->stride0;
+ else
+ stride = gfc_conv_array_stride (info->descriptor, dim);
+ }
- /* Add the offset for this dimension to the stored offset for all other
- dimensions. */
- info->current_elem.index = fold_build2_loc (input_location, PLUS_EXPR,
- gfc_array_index_type,
- info->current_elem.index, index);
+ conv_array_index_dim (&info->current_elem, index, stride);
}
@@ -3711,7 +3727,7 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar,
else
n = 0;
- conv_array_index_offset (se, ss, ss->dim[n], n, ar, info->stride0);
+ conv_array_index_offset (se, ss, ss->dim[n], n, ar);
index = info->current_elem.index;
base = build_fold_indirect_ref_loc (input_location, info->current_elem.base);
@@ -4018,15 +4034,13 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo *loop, gfc_ss *ss,
{
gfc_se se;
gfc_array_info *info;
- tree stride;
info = &ss->info->data.array;
gfc_init_se (&se, NULL);
se.loop = loop;
se.expr = info->descriptor;
- stride = gfc_conv_array_stride (info->descriptor, array_dim);
- conv_array_index_offset (&se, ss, array_dim, loop_dim, ar, stride);
+ conv_array_index_offset (&se, ss, array_dim, loop_dim, ar);
gfc_add_block_to_block (pblock, &se.pre);
info->current_elem.index = gfc_evaluate_now (info->current_elem.index, pblock);
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 5bcf4cae8f2e..384c8544aa7e 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -192,7 +192,7 @@ typedef struct gfc_array_ref_info
};
access_type access;
- tree index;
+ tree cst_index, index;
}
gfc_array_ref_info;
More information about the Gcc-cvs
mailing list