https://gcc.gnu.org/g:d4c6ca5a64c9f32b0fa316930f2635b6ca2557dc
commit d4c6ca5a64c9f32b0fa316930f2635b6ca2557dc Author: Mikael Morin <mik...@gcc.gnu.org> Date: Sat Aug 16 18:58:19 2025 +0200 Refactor set_dimension_bounds/shift_dimension_bounds Diff: --- gcc/fortran/trans-descriptor.cc | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index 81e172e8738a..09c63d0cbf68 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -1291,7 +1291,7 @@ shift_dimension_fields (stmtblock_t * block, tree descr, tree dim, { tree stride = gfc_evaluate_now (orig_stride, block); shift_dimension_bounds (block, descr, dim, new_lbound, orig_lbound, orig_ubound, - stride, *offset_value); + stride, offset_value); gfc_conv_descriptor_dimension_set (block, descr, dim, stride); } @@ -2464,38 +2464,21 @@ gfc_set_descriptor_for_assign_realloc (stmtblock_t *block, gfc_loopinfo *loop, tree tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, loop->to[n], loop->from[n]); - tmp = fold_build2_loc (input_location, PLUS_EXPR, - gfc_array_index_type, - tmp, gfc_index_one_node); - - tree lbound = gfc_index_one_node; - tree ubound = tmp; + tree ubound = fold_build2_loc (input_location, PLUS_EXPR, + gfc_array_index_type, + tmp, gfc_index_one_node); if (as) - { - tree lbd = get_std_lbound (expr2, desc2, n, - as->type == AS_ASSUMED_SIZE); - ubound = fold_build2_loc (input_location, - MINUS_EXPR, - gfc_array_index_type, - ubound, lbound); - ubound = fold_build2_loc (input_location, - PLUS_EXPR, - gfc_array_index_type, - ubound, lbd); - lbound = lbd; - } + shift_dimension_fields (block, desc, gfc_rank_cst[n], + get_std_lbound (expr2, desc2, n, + as->type == AS_ASSUMED_SIZE), + gfc_index_one_node, ubound, size1, &offset); + else + set_dimension_fields (block, desc, gfc_rank_cst[n], gfc_index_one_node, + ubound, size1, &offset); - gfc_conv_descriptor_lbound_set (block, desc, gfc_rank_cst[n], lbound); - gfc_conv_descriptor_ubound_set (block, desc, gfc_rank_cst[n], ubound); - gfc_conv_descriptor_stride_set (block, desc, gfc_rank_cst[n], size1); - lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[n]); - tree tmp2 = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, - lbound, size1); - offset = fold_build2_loc (input_location, MINUS_EXPR, - gfc_array_index_type, offset, tmp2); size1 = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, - tmp, size1); + ubound, size1); } /* Set the lhs descriptor and scalarizer offsets. For rank > 1,