This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] [05/21] Remove coarray support in the scalarizer: Calculate codim earlier.


In the next patches, we are going to evaluate cobounds out of the scalarizer.
This needs to be done before the call to gfc_get_array_type_bounds (which takes
[co]bounds as input).
As a result we need to know the corank before that call.
Furthermore, as we are going to remove coarray support in the scalarizer, let's
calculate the corank without relying on the scalarizer.
This patch just does that.

A new want_coarray flag is introduced as sometimes we want to treat coarrays
as normal arrays, that is we want a descriptor for the local image only.

OK?

Attachment: no_coarray_in_scalarizer-5.CL
Description: Text document

diff --git a/trans-array.c b/trans-array.c
index 88849ef..88998de 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -5988,6 +5988,11 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
       tree to;
       tree base;
 
+      if (se->want_coarray)
+	codim = gfc_get_corank (expr);
+      else
+	codim = 0;
+
       /* Set the string_length for a character array.  */
       if (expr->ts.type == BT_CHARACTER)
 	se->string_length =  gfc_get_expr_charlen (expr);
@@ -6036,7 +6041,6 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
 	base = NULL_TREE;
 
       ndim = info->ref ? info->ref->u.ar.dimen : info->dimen;
-      codim = info->codimen;
       for (n = 0; n < ndim; n++)
 	{
 	  stride = gfc_conv_array_stride (desc, n);
diff --git a/trans-intrinsic.c b/trans-intrinsic.c
index de5a809..c216873 100644
--- a/trans-intrinsic.c
+++ b/trans-intrinsic.c
@@ -974,6 +974,7 @@ trans_this_image (gfc_se * se, gfc_expr *expr)
   ss = gfc_walk_expr (expr->value.function.actual->expr);
   gcc_assert (ss != gfc_ss_terminator);
   ss->data.info.codimen = corank;
+  argse.want_coarray = 1;
   gfc_conv_expr_descriptor (&argse, expr->value.function.actual->expr, ss);
   gfc_add_block_to_block (&se->pre, &argse.pre);
   gfc_add_block_to_block (&se->post, &argse.post);
@@ -1161,6 +1162,7 @@ trans_image_index (gfc_se * se, gfc_expr *expr)
   ss = gfc_walk_expr (expr->value.function.actual->expr);
   gcc_assert (ss != gfc_ss_terminator);
   ss->data.info.codimen = corank;
+  argse.want_coarray = 1;
   gfc_conv_expr_descriptor (&argse, expr->value.function.actual->expr, ss);
   gfc_add_block_to_block (&se->pre, &argse.pre);
   gfc_add_block_to_block (&se->post, &argse.post);
@@ -1488,6 +1490,7 @@ conv_intrinsic_cobound (gfc_se * se, gfc_expr * expr)
   gcc_assert (ss != gfc_ss_terminator);
   ss->data.info.codimen = corank;
   gfc_init_se (&argse, NULL);
+  argse.want_coarray = 1;
 
   gfc_conv_expr_descriptor (&argse, arg->expr, ss);
   gfc_add_block_to_block (&se->pre, &argse.pre);
diff --git a/trans.h b/trans.h
index 0c249a6..6157a88 100644
--- a/trans.h
+++ b/trans.h
@@ -86,6 +86,8 @@ typedef struct gfc_se
      args alias.  */
   unsigned force_tmp:1;
 
+  unsigned want_coarray:1;
+
   /* Scalarization parameters.  */
   struct gfc_se *parent;
   struct gfc_ss *ss;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]