[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Introduction gfc_conv_descriptor_extent_get

Mikael Morin via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:4d5db6e67b03ed6f59d13c27f171e47e6d248e1c

commit 4d5db6e67b03ed6f59d13c27f171e47e6d248e1c
Author: Mikael Morin <[email protected]>
Date:   Sat Sep 6 16:34:11 2025 +0200

    Introduction gfc_conv_descriptor_extent_get
    
    Modif implémentation descriptor_extent_get
    
    Correction motif bind_c_array_params_2
    
    Ajout motif dump coarray_lock_7
    
    Correction dump intrinsic_size_3
    
    Mise à jour motif dump pr48636
    
    Correction motif dump intrinsic_size_3
    
    Correction motif dump bind_c_array_params_2
    
    Correction motif dump coarray_lock_7
    
    Correction motif dump coarray_lock_7.f90
    
    Correction motif dump intrinsic_size_3.f90
    
    Correction motif dum bind_c_array_params_2.f90
    
    Correction motif dump array_reference_3.f90

Diff:
---
 gcc/fortran/trans-array.cc                         | 20 ++-----------
 gcc/fortran/trans-decl.cc                          |  6 +---
 gcc/fortran/trans-descriptor.cc                    | 33 ++++++++++-----------
 gcc/fortran/trans-descriptor.h                     |  1 +
 gcc/fortran/trans-expr.cc                          |  9 ++----
 gcc/fortran/trans-intrinsic.cc                     | 30 +++++--------------
 gcc/fortran/trans-openmp.cc                        | 34 ++++------------------
 gcc/fortran/trans-stmt.cc                          | 10 +++----
 gcc/testsuite/gfortran.dg/array_reference_3.f90    |  2 +-
 .../gfortran.dg/bind_c_array_params_2.f90          |  4 +--
 gcc/testsuite/gfortran.dg/coarray_lock_7.f90       |  4 +--
 gcc/testsuite/gfortran.dg/intrinsic_size_3.f90     |  2 +-
 gcc/testsuite/gfortran.dg/pr48636.f90              |  2 +-
 13 files changed, 47 insertions(+), 110 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 6ec51b3ef9e7..a3e276d07458 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -8243,13 +8243,8 @@ gfc_tree_array_size (stmtblock_t *block, tree desc, gfc_expr *expr, tree dim)
 	dim = fold_convert_loc (input_location, gfc_array_dim_rank_type, dim);
       else
 	dim = gfc_rank_cst[0];
-      tree ubound = gfc_conv_descriptor_ubound_get (desc, dim);
-      tree lbound = gfc_conv_descriptor_lbound_get (desc, dim);
 
-      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_descriptor_extent_get (desc, dim);
       /* if (!allocatable && !pointer && assumed rank)
 	   size = (idx == rank && ubound[rank-1] == -1 ? -1 : size;
 	 else
@@ -8310,11 +8305,7 @@ gfc_tree_array_size (stmtblock_t *block, tree desc, gfc_expr *expr, tree dim)
       cond = fold_build2_loc (input_location, TRUTH_AND_EXPR, boolean_type_node,
 			      cond, tmp);
     }
-  tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-			 gfc_conv_descriptor_ubound_get (desc, idx),
-			 gfc_conv_descriptor_lbound_get (desc, idx));
-  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-			 tmp, gfc_index_one_node);
+  tmp = gfc_conv_descriptor_extent_get (desc, idx);
   gfc_add_modify (&cond_block, extent, tmp);
   tmp = fold_build2_loc (input_location, LT_EXPR, boolean_type_node,
 			 extent, gfc_index_zero_node);
@@ -8898,12 +8889,7 @@ gfc_full_array_size (stmtblock_t *block, tree decl, int rank)
     idx = gfc_conv_descriptor_rank_get (decl);
   else
     idx = gfc_rank_cst[rank - 1];
-  nelems = gfc_conv_descriptor_ubound_get (decl, idx);
-  tmp = gfc_conv_descriptor_lbound_get (decl, idx);
-  tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-			 nelems, tmp);
-  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-			 tmp, gfc_index_one_node);
+  tmp = gfc_conv_descriptor_extent_get (decl, idx);
   tmp = gfc_evaluate_now (tmp, block);
 
   nelems = gfc_conv_descriptor_stride_get (decl, idx);
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index cdd1494c2ba1..d28a8eec099d 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -7863,11 +7863,7 @@ done:
   gfc_add_modify (&loop_body, gfc_get_cfi_dim_lbound (cfi, idx),
 		  gfc_conv_descriptor_lbound_get (gfc_desc, idx));
   /* cfi->dim[i].extent = gfc->dim[i].ubound - gfc->dim[i].lbound + 1.  */
-  tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-			     gfc_conv_descriptor_ubound_get (gfc_desc, idx),
-			     gfc_conv_descriptor_lbound_get (gfc_desc, idx));
-  tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, tmp,
-			 gfc_index_one_node);
+  tmp = gfc_conv_descriptor_extent_get (gfc_desc, idx);
   gfc_add_modify (&loop_body, gfc_get_cfi_dim_extent (cfi, idx), tmp);
   /* d->dim[n].sm = gfc->dim[i].stride  * gfc->span); */
   tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 1f800129640f..0dab0cdd2cc6 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -641,6 +641,19 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off,
 }
 
 
+tree
+gfc_conv_descriptor_extent_get (tree desc, tree dim)
+{
+  tree lbound = gfc_conv_descriptor_lbound_get (desc, dim);
+  tree ubound = gfc_conv_descriptor_ubound_get (desc, dim);
+
+  tree tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			      lbound, gfc_index_one_node);
+  return fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+			  ubound, tmp);
+}
+
+
 /* Array descriptor higher level routines.
  ******************************************************************************/
 
@@ -773,14 +786,7 @@ gfc_conv_descriptor_size_1 (tree desc, int from_dim, int to_dim)
 
   for (dim = from_dim; dim < to_dim; ++dim)
     {
-      tree lbound;
-      tree ubound;
-      tree extent;
-
-      lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim]);
-      ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[dim]);
-
-      extent = gfc_conv_array_extent_dim (lbound, ubound, NULL);
+      tree extent = gfc_conv_descriptor_extent_get (desc, gfc_rank_cst[dim]);
       res = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
 			     res, extent);
     }
@@ -2812,15 +2818,8 @@ gfc_descriptor_init_count (tree descriptor, int rank, int corank,
 		 start at zero, but when allocating it, the standard expects
 		 the array to start at one.  Therefore fix the upper bound to be
 		 (desc.ubound - desc.lbound) + 1.  */
-	      tmp = fold_build2_loc (input_location, MINUS_EXPR,
-				     gfc_array_index_type,
-				     gfc_conv_descriptor_ubound_get (
-				       expr3_desc, gfc_rank_cst[n]),
-				     gfc_conv_descriptor_lbound_get (
-				       expr3_desc, gfc_rank_cst[n]));
-	      tmp = fold_build2_loc (input_location, PLUS_EXPR,
-				     gfc_array_index_type, tmp,
-				     gfc_index_one_node);
+	      tmp = gfc_conv_descriptor_extent_get (expr3_desc,
+						    gfc_rank_cst[n]);
 	      se.expr = gfc_evaluate_now (tmp, pblock);
 	    }
 	  else
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 03766cde2bfd..62f84c909bfc 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -36,6 +36,7 @@ tree gfc_conv_descriptor_stride_get (tree, tree);
 tree gfc_conv_descriptor_lbound_get (tree, tree);
 tree gfc_conv_descriptor_ubound_get (tree, tree);
 tree gfc_conv_descriptor_sm_get (tree desc, tree dim);
+tree gfc_conv_descriptor_extent_get (tree desc, tree dim);
 
 void gfc_conv_descriptor_data_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_dtype_set (stmtblock_t *, tree, tree);
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 2260b8c0bb26..6401daa2baa3 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -2547,8 +2547,7 @@ gfc_caf_get_image_index (stmtblock_t *block, gfc_expr *e, tree desc)
 				   TREE_TYPE (tmp), img_idx, tmp);
 	if (i < ref->u.ar.dimen + ref->u.ar.codimen - 1)
 	  {
-	    ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
-	    tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
+	    tmp = gfc_conv_descriptor_extent_get (desc, gfc_rank_cst[i]);
 	    extent = fold_build2_loc (input_location, MULT_EXPR,
 				      TREE_TYPE (tmp), extent, tmp);
 	  }
@@ -6274,11 +6273,7 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
 	tmp = gfc_index_zero_node;
       gfc_add_modify (&loop_body, gfc_get_cfi_dim_lbound (cfi, idx), tmp);
       /* cfi->dim[i].extent = gfc->dim[i].ubound - gfc->dim[i].lbound + 1.  */
-      tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-			     gfc_conv_descriptor_ubound_get (gfc, idx),
-			     gfc_conv_descriptor_lbound_get (gfc, idx));
-      tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-			     tmp, gfc_index_one_node);
+      tmp = gfc_conv_descriptor_extent_get (gfc, idx);
       gfc_add_modify (&loop_body, gfc_get_cfi_dim_extent (cfi, idx), tmp);
       /* d->dim[n].sm = gfc->dim[i].stride * gfc->span); */
       tmp = gfc_conv_descriptor_sm_get (gfc, idx);
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 6a3145e0045c..42a1c7ff96bb 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -1825,7 +1825,7 @@ trans_this_image (gfc_se * se, gfc_expr *expr)
 {
   stmtblock_t loop;
   tree type, desc, dim_arg, cond, tmp, m, loop_var, exit_label, min_var, lbound,
-    ubound, extent, ml, team;
+      extent, ml, team;
   gfc_se argse;
   int rank, corank;
 
@@ -1992,9 +1992,7 @@ trans_this_image (gfc_se * se, gfc_expr *expr)
   gfc_add_modify (&loop, ml, m);
 
   /* extent = ...  */
-  lbound = gfc_conv_descriptor_lbound_get (desc, loop_var);
-  ubound = gfc_conv_descriptor_ubound_get (desc, loop_var);
-  extent = gfc_conv_array_extent_dim (lbound, ubound, NULL);
+  extent = gfc_conv_descriptor_extent_get (desc, loop_var);
   extent = fold_convert (type, extent);
 
   /* m = m/extent.  */
@@ -2205,12 +2203,10 @@ trans_image_index (gfc_se * se, gfc_expr *expr)
 
   for (codim = corank + rank - 2; codim >= rank; codim--)
     {
-      tree extent, ubound;
+      tree extent;
 
       /* coindex = coindex*extent(codim) + sub(codim) - lcobound(codim).  */
-      lbound = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[codim]);
-      ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[codim]);
-      extent = gfc_conv_array_extent_dim (lbound, ubound, NULL);
+      extent = gfc_conv_descriptor_extent_get (desc, gfc_rank_cst[codim]);
 
       /* coindex *= extent.  */
       coindex = fold_build2_loc (input_location, MULT_EXPR,
@@ -2366,13 +2362,7 @@ gfc_conv_is_contiguous_expr (gfc_se *se, gfc_expr *arg)
 
       for (i = 0; i < arg->rank - 1; i++)
 	{
-	  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_descriptor_extent_get (desc, gfc_rank_cst[i]);
 	  tmp = gfc_conv_descriptor_stride_get (desc, gfc_rank_cst[i]);
 	  tmp = fold_build2_loc (input_location, MULT_EXPR, TREE_TYPE (tmp),
 				 tmp, extent);
@@ -2510,10 +2500,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_descriptor_extent_get (desc, bound);
 
   /* 13.14.53: Result value for LBOUND
 
@@ -13055,7 +13042,7 @@ conv_intrinsic_event_query (gfc_code *code)
       /* For arrays, obtain the array index.  */
       if (gfc_expr_attr (event_expr).dimension)
 	{
-	  tree desc, tmp, extent, lbound, ubound;
+	  tree desc, tmp, extent, lbound;
           gfc_array_ref *ar, ar2;
           int i;
 
@@ -13088,8 +13075,7 @@ conv_intrinsic_event_query (gfc_code *code)
 				       TREE_TYPE (tmp), index, tmp);
 	      if (i < ar->dimen - 1)
 		{
-		  ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
-		  tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
+		  tmp = gfc_conv_descriptor_extent_get (desc, gfc_rank_cst[i]);
 		  extent = fold_build2_loc (input_location, MULT_EXPR,
 					    TREE_TYPE (tmp), extent, tmp);
 		}
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 52b1554ac338..57ca98205b54 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -873,12 +873,7 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree outer)
     {
       gfc_add_modify (&cond_block, decl, outer);
       tree rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
-      size = gfc_conv_descriptor_ubound_get (decl, rank);
-      size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-			      size,
-			      gfc_conv_descriptor_lbound_get (decl, rank));
-      size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-			      size, gfc_index_one_node);
+      size = gfc_conv_descriptor_extent_get (decl, rank);
       if (GFC_TYPE_ARRAY_RANK (type) > 1)
 	size = fold_build2_loc (input_location, MULT_EXPR,
 				gfc_array_index_type, size,
@@ -1071,12 +1066,7 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src)
   if (GFC_DESCRIPTOR_TYPE_P (type))
     {
       tree rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
-      size = gfc_conv_descriptor_ubound_get (dest, rank);
-      size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-			      size,
-			      gfc_conv_descriptor_lbound_get (dest, rank));
-      size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-			      size, gfc_index_one_node);
+      size = gfc_conv_descriptor_extent_get (dest, rank);
       if (GFC_TYPE_ARRAY_RANK (type) > 1)
 	size = fold_build2_loc (input_location, MULT_EXPR,
 				gfc_array_index_type, size,
@@ -1194,12 +1184,7 @@ gfc_omp_clause_assign_op (tree clause, tree dest, tree src)
   if (GFC_DESCRIPTOR_TYPE_P (type))
     {
       tree rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
-      size = gfc_conv_descriptor_ubound_get (src, rank);
-      size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-			      size,
-			      gfc_conv_descriptor_lbound_get (src, rank));
-      size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-			      size, gfc_index_one_node);
+      size = gfc_conv_descriptor_extent_get (src, rank);
       if (GFC_TYPE_ARRAY_RANK (type) > 1)
 	size = fold_build2_loc (input_location, MULT_EXPR,
 				gfc_array_index_type, size,
@@ -1425,12 +1410,7 @@ gfc_omp_clause_linear_ctor (tree clause, tree dest, tree src, tree add)
   if (GFC_DESCRIPTOR_TYPE_P (type))
     {
       tree rank = gfc_rank_cst[GFC_TYPE_ARRAY_RANK (type) - 1];
-      size = gfc_conv_descriptor_ubound_get (dest, rank);
-      size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
-			      size,
-			      gfc_conv_descriptor_lbound_get (dest, rank));
-      size = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
-			      size, gfc_index_one_node);
+      size = gfc_conv_descriptor_extent_get (dest, rank);
       if (GFC_TYPE_ARRAY_RANK (type) > 1)
 	size = fold_build2_loc (input_location, MULT_EXPR,
 				gfc_array_index_type, size,
@@ -2144,11 +2124,7 @@ gfc_omp_get_array_size (location_t loc, tree desc, gimple_seq *seq)
   gfc_omp_gen_simple_loop (idx, begin, end, LT_EXPR, step, loc, &seq1, &seq2);
   gimple_seq_add_seq (seq, seq1);
 
-  tmp = fold_build2_loc (loc, MINUS_EXPR, gfc_array_index_type,
-			 gfc_conv_descriptor_ubound_get (desc, idx),
-			 gfc_conv_descriptor_lbound_get (desc, idx));
-  tmp = fold_build2_loc (loc, PLUS_EXPR, gfc_array_index_type,
-			 tmp, gfc_index_one_node);
+  tmp = gfc_conv_descriptor_extent_get (desc, idx);
   gimplify_assign (extent, tmp, seq);
   tmp = fold_build2_loc (loc, LT_EXPR, boolean_type_node,
 			 extent, gfc_index_zero_node);
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index 2c88691e4a60..199e36ad2307 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -1049,7 +1049,7 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
       /* For arrays, obtain the array index.  */
       if (gfc_expr_attr (code->expr1).dimension)
 	{
-	  tree desc, tmp, extent, lbound, ubound;
+	  tree desc, tmp, extent, lbound;
 	  gfc_array_ref *ar, ar2;
 	  int i, rank;
 
@@ -1085,8 +1085,7 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
 				       TREE_TYPE (tmp), index, tmp);
 	      if (i < ar->dimen - 1)
 		{
-		  ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
-		  tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
+		  tmp = gfc_conv_descriptor_extent_get (desc, gfc_rank_cst[i]);
 		  extent = fold_build2_loc (input_location, MULT_EXPR,
 					    TREE_TYPE (tmp), extent, tmp);
 		}
@@ -1250,7 +1249,7 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
   /* For arrays, obtain the array index.  */
   if (gfc_expr_attr (code->expr1).dimension)
     {
-      tree desc, tmp, extent, lbound, ubound;
+      tree desc, tmp, extent, lbound;
       gfc_array_ref *ar, ar2;
       int i;
 
@@ -1283,8 +1282,7 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
 				   TREE_TYPE (tmp), index, tmp);
 	  if (i < ar->dimen - 1)
 	    {
-	      ubound = gfc_conv_descriptor_ubound_get (desc, gfc_rank_cst[i]);
-	      tmp = gfc_conv_array_extent_dim (lbound, ubound, NULL);
+	      tmp = gfc_conv_descriptor_extent_get (desc, gfc_rank_cst[i]);
 	      extent = fold_build2_loc (input_location, MULT_EXPR,
 					TREE_TYPE (tmp), extent, tmp);
 	    }
diff --git a/gcc/testsuite/gfortran.dg/array_reference_3.f90 b/gcc/testsuite/gfortran.dg/array_reference_3.f90
index a10467fe3e08..31891c64477e 100644
--- a/gcc/testsuite/gfortran.dg/array_reference_3.f90
+++ b/gcc/testsuite/gfortran.dg/array_reference_3.f90
@@ -65,7 +65,7 @@ contains
     call ccfis(x)
     if (any(x /= 13)) stop 13
     ! The cfi descriptor’s dim array is referenced with array indexing.
-    ! { dg-final { scan-tree-dump-times {cfi_descriptor->dim\[[^]]+\]\.ubound = _cfi_descriptor->dim\[[^]]+\]\.extent \+ \(D\.\d+ \+ -1\);} 1 "original" } }
+    ! { dg-final { scan-tree-dump-times {cfi_descriptor->dim\[[^]]+\]\.ubound = NON_LVALUE_EXPR <_cfi_descriptor->dim\[[^]]+\]\.extent>;} 1 "original" } }
   end subroutine check_cfi_dim
   subroutine css(c) bind(c)
     character :: c
diff --git a/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90 b/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
index aa6a37b48504..f3943570f979 100644
--- a/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
+++ b/gcc/testsuite/gfortran.dg/bind_c_array_params_2.f90
@@ -46,8 +46,8 @@ end
 
 ! { dg-final { scan-tree-dump "if \\(idx.. <= 1\\) goto L..;" "original" } }
 ! { dg-final { scan-tree-dump "cfi...dim\\\[idx..\\\].lower_bound = 0;" "original" } }
-! { dg-final { scan-tree-dump "cfi...dim\\\[idx..\\\].extent = \\(parm...dim\\\[idx..\\\].ubound - parm...dim\\\[idx..\\\].lbound\\) \\+ 1;" "original" } }
-! { dg-final { scan-tree-dump "cfi...dim\\\[idx..\\\].sm = parm...dim\\\[idx..\\\].stride \\* parm...span;" "original" } }
+! { dg-final { scan-tree-dump {cfi..\.dim\[idx..\]\.extent = parm..\.dim\[idx..\]\.ubound - \(parm..\.dim\[idx..\]\.lbound \+ -1\);} "original" } }
+! { dg-final { scan-tree-dump {cfi..\.dim\[idx..\]\.sm = parm..\.dim\[idx..\]\.stride \* parm..\.span;} "original" } }
 ! { dg-final { scan-tree-dump "idx.. = idx.. \\+ 1;" "original" } }
 
 ! { dg-final { scan-tree-dump "test \\(&cfi..\\);" "original" } }
diff --git a/gcc/testsuite/gfortran.dg/coarray_lock_7.f90 b/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
index 4f4bdde856d9..ae080b2b1982 100644
--- a/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_lock_7.f90
@@ -35,8 +35,8 @@ end
 ! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., 0, 0, 0B, 0B, 0B, 0\\);" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., 0, 0, 0B, 0B, 0\\);" 1 "original" } }
 
-! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(caf_token.., .*\\(\\(3 - parm.\\d+.dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm.\\d+.dim\\\[0\\\].ubound - parm.\\d+.dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm.\\d+.dim\\\[1\\\].lbound\\)\\), 0, 0B, &ii, 0B, 0\\);|_gfortran_caf_lock \\(caf_token.1, \\(3 - parm.\\d+.dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm.\\d+.dim\\\[0\\\].ubound - parm.\\d+.dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm.\\d+.dim\\\[1\\\].lbound\\), 0, 0B, &ii, 0B, 0\\);" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(caf_token.., .*\\(\\(2 - parm.\\d+.dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm.\\d+.dim\\\[0\\\].ubound - parm.\\d+.dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm.\\d+.dim\\\[1\\\].lbound\\)\\), 0, &ii, 0B, 0\\);|_gfortran_caf_unlock \\(caf_token.., \\(2 - parm.\\d+.dim\\\[0\\\].lbound\\) \\+ \\(MAX_EXPR <parm.\\d+.dim\\\[0\\\].ubound - parm.\\d+.dim\\\[0\\\].lbound, -1> \\+ 1\\) \\* \\(3 - parm.\\d+.dim\\\[1\\\].lbound\\), 0, &ii, 0B, 0\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times {_gfortran_caf_lock \(caf_token.., .*\(\(3 - parm.\d+\.dim\[0\]\.lbound\) \+ \(parm.\d+\.dim\[0\].ubound - \(parm.\d+\.dim\[0\]\.lbound \+ -1\)\) \* \(3 - parm.\d+\.dim\[1\]\.lbound\)\), 0, 0B, &ii, 0B, 0\);} 1 "original" } }
+! { dg-final { scan-tree-dump-times {_gfortran_caf_unlock \(caf_token.., .*\(\(2 - parm.\d+\.dim\[0\]\.lbound\) \+ \(parm.\d+\.dim\[0\]\.ubound - \(parm.\d+\.dim\[0\]\.lbound \+ -1\)\) \* \(3 - parm.\d+\.dim\[1\]\.lbound\)\), 0, &ii, 0B, 0\);} 1 "original" } }
 
 ! { dg-final { scan-tree-dump-times "_gfortran_caf_lock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(5 - three.dim\\\[0\\\].lbound\\), &acquired.\[0-9\]+, 0B, 0B, 0\\);|_gfortran_caf_lock \\(three.token, 0, 5 - three.dim\\\[0\\\].lbound, &acquired.\[0-9\]+, 0B, 0B, 0\\);" 1 "original" } }
 ! { dg-final { scan-tree-dump-times "_gfortran_caf_unlock \\(three.token, 0, \\(integer\\(kind=4\\)\\) \\(8 - three.dim\\\[0\\\].lbound\\), &ii, 0B, 0\\);|_gfortran_caf_unlock \\(three.token, 0, 8 - three.dim\\\[0\\\].lbound, &ii, 0B, 0\\);" 1 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/intrinsic_size_3.f90 b/gcc/testsuite/gfortran.dg/intrinsic_size_3.f90
index afdf9b34d4bc..a188402af68b 100644
--- a/gcc/testsuite/gfortran.dg/intrinsic_size_3.f90
+++ b/gcc/testsuite/gfortran.dg/intrinsic_size_3.f90
@@ -22,4 +22,4 @@ program bug
   stop
 end program bug
 
-! { dg-final { scan-tree-dump-times "iszs = \\(integer\\(kind=2\\)\\) MAX_EXPR <\\(a.dim.0..ubound - a.dim.0..lbound\\) \\+ 1, 0>;" 1 "original" } }
+! { dg-final { scan-tree-dump-times {iszs = \(integer\(kind=2\)\) MAX_EXPR <a\.dim\[0\]\.ubound - \(a\.dim\[0\]\.lbound \+ -1\), 0>;} 1 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/pr48636.f90 b/gcc/testsuite/gfortran.dg/pr48636.f90
index cb5b4d7a553a..0e265e5955b5 100644
--- a/gcc/testsuite/gfortran.dg/pr48636.f90
+++ b/gcc/testsuite/gfortran.dg/pr48636.f90
@@ -34,5 +34,5 @@ program main
 end program main
 
 ! { dg-final { scan-ipa-dump "bar\[^\\n\]*inline copy in MAIN" "inline" } }
-! { dg-final { scan-ipa-dump-times "phi predicate:" 3 "fnsummary" } }
+! { dg-final { scan-ipa-dump-times "phi predicate:" 1 "fnsummary" } }
 ! { dg-final { scan-ipa-dump "IPA hints: loop_iterations" "inline" } }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.