[gcc(refs/users/mikael/heads/refactor_descriptor_v08)] Déplacement évaluation stride
Mikael Morin
mikael@gcc.gnu.org
Wed Sep 17 17:41:46 GMT 2025
https://gcc.gnu.org/g:0a6a521abf8125a9fae38225ee1ceed478a08bbc
commit 0a6a521abf8125a9fae38225ee1ceed478a08bbc
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
Correction index stride0
Diff:
---
gcc/fortran/trans-array.cc | 40 +++++++++++++++++++++++++++-------------
gcc/fortran/trans.h | 2 +-
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index d082e2d7a8f6..36d1dbcf3056 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3452,18 +3452,34 @@ array_bound_check_elemental (gfc_se * se, gfc_ss * ss, gfc_expr * expr)
}
+static tree
+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. */
+ return 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 tree
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,15 +3575,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 (ss->nested_ss == nullptr && i == 0)
+ 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. */
- return fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
- info->current_elem.index, index);
+ return conv_array_index_dim (&info->current_elem, index, stride);
}
@@ -3710,7 +3726,7 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar,
else
n = 0;
- index = conv_array_index_offset (se, ss, ss->dim[n], n, ar, info->stride0);
+ index = conv_array_index_offset (se, ss, ss->dim[n], n, ar);
base = build_fold_indirect_ref_loc (input_location, info->current_elem.base);
@@ -4016,7 +4032,6 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo *loop, gfc_ss *ss,
{
gfc_se se;
gfc_array_info *info;
- tree stride;
tree index;
info = &ss->info->data.array;
@@ -4024,8 +4039,7 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo *loop, gfc_ss *ss,
gfc_init_se (&se, NULL);
se.loop = loop;
se.expr = info->descriptor;
- stride = gfc_conv_array_stride (info->descriptor, array_dim);
- index = conv_array_index_offset (&se, ss, array_dim, loop_dim, ar, stride);
+ index = 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 (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