https://gcc.gnu.org/g:304c2fcfe39a545ce8fce8a19533b21f2dadea05
commit 304c2fcfe39a545ce8fce8a19533b21f2dadea05 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Sat Aug 16 18:41:13 2025 +0200 Factorisation shift_dimension_bounds set_dimension_bounds Diff: --- gcc/fortran/trans-descriptor.cc | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index d226ca85b037..623bf4d8281c 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -2330,39 +2330,13 @@ gfc_set_temporary_descriptor (stmtblock_t *block, tree descr, tree class_src, if (!callee_allocated) for (int n = 0; n < rank; n++) { - /* Store the stride and bound components in the descriptor. */ - gfc_conv_descriptor_stride_set (block, descr, gfc_rank_cst[n], - stride[n]); - - tree this_lbound = shift_bounds ? gfc_index_zero_node : lbound[n]; - gfc_conv_descriptor_lbound_set (block, descr, gfc_rank_cst[n], - this_lbound); - - tree this_ubound; if (shift_bounds) - { - tree lbound_diff = fold_build2_loc (input_location, MINUS_EXPR, - gfc_array_index_type, - this_lbound, lbound[n]); - this_ubound = fold_build2_loc (input_location, PLUS_EXPR, - gfc_array_index_type, - ubound[n], lbound_diff); - } + shift_dimension_bounds (block, descr, gfc_rank_cst[n], + gfc_index_zero_node, lbound[n], ubound[n], + stride[n], &offset); else - this_ubound = ubound[n]; - - gfc_conv_descriptor_ubound_set (block, descr, gfc_rank_cst[n], - this_ubound); - - if (!shift_bounds) - { - tree tmp = fold_build2_loc (input_location, MULT_EXPR, - gfc_array_index_type, this_lbound, - stride[n]); - tmp = fold_build2_loc (input_location, MINUS_EXPR, - gfc_array_index_type, offset, tmp); - offset = gfc_evaluate_now (tmp, block); - } + set_dimension_bounds (block, descr, gfc_rank_cst[n], lbound[n], + ubound[n], stride[n], &offset); } gfc_conv_descriptor_span_set (block, descr, elemsize);