https://gcc.gnu.org/g:b3352e2b70f2e2b89d578b12ea32341830e27109

commit b3352e2b70f2e2b89d578b12ea32341830e27109
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Sat Mar 29 12:50:41 2025 +0100

    Factorisation gfc_conv_array_extent_dim

Diff:
---
 gcc/fortran/trans-intrinsic.cc | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 3cc9f5d9c7bc..b887a2ff7a1a 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -2359,11 +2359,7 @@ gfc_conv_is_contiguous_expr (gfc_se *se, gfc_expr *arg)
        {
          tmp = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[i]);
          extent = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
-         extent = fold_build2_loc (input_location, MINUS_EXPR,
-                                   gfc_array_index_type, extent, tmp);
-         extent = fold_build2_loc (input_location, PLUS_EXPR,
-                                   gfc_array_index_type, extent,
-                                   gfc_index_one_node);
+         extent = gfc_conv_array_extent_dim (tmp, extent, nullptr);
          tmp = gfc_conv_descriptor_stride_get (desc, gfc_rank_cst[i]);
          tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
                                 tmp, extent);
@@ -2483,10 +2479,7 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, 
enum gfc_isym_id op)
 
   ubound = gfc_conv_descriptor_ubound_get (desc, bound);
   lbound = gfc_conv_descriptor_lbound_get (desc, bound);
-  size = fold_build2_loc (input_location, MINUS_EXPR,
-                         gfc_array_index_type, ubound, lbound);
-  size = fold_build2_loc (input_location, PLUS_EXPR,
-                         gfc_array_index_type, size, gfc_index_one_node);
+  size = gfc_conv_array_extent_dim (lbound, ubound, nullptr);
 
   /* 13.14.53: Result value for LBOUND

Reply via email to