[gcc(refs/users/mikael/heads/refactor_descriptor_v08)] Refactoring set_dimension_fields
Mikael Morin
mikael@gcc.gnu.org
Wed Sep 17 16:49:53 GMT 2025
https://gcc.gnu.org/g:5243a81e4852ae0823230ca46e4e94498e23fb67
commit 5243a81e4852ae0823230ca46e4e94498e23fb67
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Sat Aug 16 16:28:37 2025 +0200
Refactoring set_dimension_fields
Diff:
---
gcc/fortran/trans-descriptor.cc | 46 ++++++++++++++++++++++++-----------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index cddffac71246..65ebfeb504a6 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -1017,6 +1017,25 @@ set_dimension_bounds (stmtblock_t * block, tree descr, tree dim,
}
+static void
+set_dimension_fields (stmtblock_t * block, tree descr, tree dim,
+ tree lbound, tree ubound, tree stride, tree *offset)
+{
+ stride = gfc_evaluate_now (stride, block);
+ set_dimension_bounds (block, descr, dim, lbound, ubound, stride, offset);
+ gfc_conv_descriptor_stride_set (block, descr, dim, stride);
+}
+
+
+static void
+set_dimension_fields (stmtblock_t * block, tree descr, tree dim,
+ tree lbound, tree ubound, tree stride, tree offset_var)
+{
+ stride = gfc_evaluate_now (stride, block);
+ set_dimension_bounds (block, descr, dim, lbound, ubound, stride, offset_var);
+ gfc_conv_descriptor_stride_set (block, descr, dim, stride);
+}
+
static void
shift_dimension_bounds (stmtblock_t * block, tree descr, tree dim,
tree new_lbound, tree orig_lbound, tree orig_ubound,
@@ -1496,22 +1515,13 @@ gfc_conv_remap_descriptor (stmtblock_t *block, tree dest, int dest_rank,
gfc_add_block_to_block (block, &lower_se.post);
gfc_add_block_to_block (block, &upper_se.post);
- /* Set bounds in descriptor. */
- gfc_conv_descriptor_lbound_set (block, dest, gfc_rank_cst[dim], lbound);
- gfc_conv_descriptor_ubound_set (block, dest, gfc_rank_cst[dim], ubound);
-
- /* Set stride. */
stride = gfc_evaluate_now (stride, block);
- gfc_conv_descriptor_stride_set (block, dest, gfc_rank_cst[dim], stride);
- /* Update offset. */
- tree tmp = fold_build2_loc (input_location, MULT_EXPR,
- gfc_array_index_type, lbound, stride);
- offset = fold_build2_loc (input_location, MINUS_EXPR,
- gfc_array_index_type, offset, tmp);
+ set_dimension_fields (block, dest, gfc_rank_cst[dim],
+ lbound, ubound, stride, &offset);
/* Update stride. */
- tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
+ tree tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
stride = fold_build2_loc (input_location, MULT_EXPR,
gfc_array_index_type, stride, tmp);
}
@@ -1852,15 +1862,13 @@ set_gfc_dimension_from_cfi (stmtblock_t *block, tree gfc, tree cfi, tree idx,
{
/* gfc->dim[i].stride = cfi->dim[i].sm / cfi>elem_len */
tmp = gfc_get_cfi_dim_sm (cfi, idx);
- tmp = fold_build2_loc (input_location, TRUNC_DIV_EXPR,
- gfc_array_index_type, tmp,
- fold_convert (gfc_array_index_type,
- gfc_get_cfi_desc_elem_len (cfi)));
- stride = gfc_evaluate_now (tmp, block);
+ stride = fold_build2_loc (input_location, TRUNC_DIV_EXPR,
+ gfc_array_index_type, tmp,
+ fold_convert (gfc_array_index_type,
+ gfc_get_cfi_desc_elem_len (cfi)));
}
- set_dimension_bounds (block, gfc, idx, lbound, ubound, stride, offset_var);
- gfc_conv_descriptor_stride_set (block, gfc, idx, stride);
+ set_dimension_fields (block, gfc, idx, lbound, ubound, stride, offset_var);
}
More information about the Gcc-cvs
mailing list