[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Initialisation shifted offset en partant de zero
Mikael Morin via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:5d60b1374af6a13043cb2f8b096b8ce17e6fed0f commit 5d60b1374af6a13043cb2f8b096b8ce17e6fed0f Author: Mikael Morin <[email protected]> Date: Thu Aug 14 11:59:54 2025 +0200 Initialisation shifted offset en partant de zero Suppression utilisation offset descripteur comme variable temporaire Diff: --- gcc/fortran/trans-descriptor.cc | 39 ++++++++++++++++++++------------------- gcc/fortran/trans-descriptor.h | 1 - 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index bc76d0c4a8e3..5416b6525bbf 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -767,19 +767,20 @@ gfc_conv_descriptor_cosize (tree desc, int rank, int corank) /* Modify a descriptor such that the lbound of a given dimension is the value specified. This also updates ubound and offset accordingly. */ -void -gfc_conv_shift_descriptor_lbound (stmtblock_t* block, tree desc, - int dim, tree new_lbound) +static void +conv_shift_descriptor_lbound (stmtblock_t* block, tree desc, + int dim, tree new_lbound, tree *offset) { - tree offs, ubound, lbound, stride; - tree diff, offs_diff; + tree ubound, lbound, stride; + tree diff; new_lbound = fold_convert (gfc_array_index_type, new_lbound); + new_lbound = gfc_evaluate_now (new_lbound, block); - offs = gfc_conv_descriptor_offset_get (desc); lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim]); ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]); stride = gfc_conv_descriptor_stride_get (desc, gfc_rank_cst[dim]); + stride = gfc_evaluate_now (stride, block); /* Get difference (new - old) by which to shift stuff. */ diff = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, @@ -790,11 +791,10 @@ gfc_conv_shift_descriptor_lbound (stmtblock_t* block, tree desc, ubound = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, ubound, diff); gfc_conv_descriptor_ubound_set (block, desc, gfc_rank_cst[dim], ubound); - offs_diff = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, - diff, stride); - offs = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, - offs, offs_diff); - gfc_conv_descriptor_offset_set (block, desc, offs); + tree tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, + new_lbound, stride); + *offset = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, + *offset, tmp); /* Finally set lbound to value we want. */ gfc_conv_descriptor_lbound_set (block, desc, gfc_rank_cst[dim], new_lbound); @@ -1080,9 +1080,11 @@ void gfc_conv_shift_descriptor (stmtblock_t* block, tree desc, int rank) { /* Apply a shift of the lbound when supplied. */ + tree offset = gfc_index_zero_node; for (int dim = 0; dim < rank; ++dim) - gfc_conv_shift_descriptor_lbound (block, desc, dim, - gfc_index_one_node); + conv_shift_descriptor_lbound (block, desc, dim, + gfc_index_one_node, &offset); + gfc_conv_descriptor_offset_set (block, desc, offset); } @@ -1091,6 +1093,7 @@ conv_shift_descriptor (stmtblock_t *block, tree desc, int rank, gfc_expr * const (lbound[GFC_MAX_DIMENSIONS])) { /* Apply a shift of the lbound when supplied. */ + tree offset = gfc_index_zero_node; for (int dim = 0; dim < rank; ++dim) { gfc_expr *lb_expr = lbound[dim]; @@ -1113,8 +1116,9 @@ conv_shift_descriptor (stmtblock_t *block, tree desc, int rank, lower_bound = lb_var; } - gfc_conv_shift_descriptor_lbound (block, desc, dim, lower_bound); + conv_shift_descriptor_lbound (block, desc, dim, lower_bound, &offset); } + gfc_conv_descriptor_offset_set (block, desc, offset); } @@ -1234,9 +1238,7 @@ gfc_set_subarray_descriptor (stmtblock_t *block, tree descr, tree value, /* Shift the lbound and ubound of temporaries to being unity, rather than zero, based. Always calculate the offset. */ - gfc_conv_descriptor_offset_set (block, descr, gfc_index_zero_node); - tree offset = gfc_conv_descriptor_offset_get (descr); - tree tmp2 = gfc_create_var (gfc_array_index_type, NULL); + tree offset = gfc_index_zero_node; for (int n = 0; n < value_expr->rank; n++) { @@ -1282,9 +1284,8 @@ gfc_set_subarray_descriptor (stmtblock_t *block, tree descr, tree value, gfc_rank_cst[n]), gfc_conv_descriptor_stride_get (descr, gfc_rank_cst[n])); - gfc_add_modify (block, tmp2, tmp); tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type, - offset, tmp2); + offset, tmp); gfc_conv_descriptor_offset_set (block, descr, tmp); } } diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h index 65e1a193d204..9e99b91049a1 100644 --- a/gcc/fortran/trans-descriptor.h +++ b/gcc/fortran/trans-descriptor.h @@ -85,7 +85,6 @@ void gfc_init_descriptor_variable (stmtblock_t *block, gfc_symbol *sym, tree des void gfc_copy_coarray_desc_part (stmtblock_t *, tree, tree); -void gfc_conv_shift_descriptor_lbound (stmtblock_t *, tree, int, tree); void gfc_conv_shift_descriptor (stmtblock_t *, tree, int); void gfc_conv_shift_descriptor (stmtblock_t *, tree, const gfc_array_ref &); void gfc_conv_shift_descriptor (stmtblock_t *, tree, tree, int, tree);