public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mikael Morin <mikael.morin@sfr.fr>
To: gfortran <fortran@gcc.gnu.org> , GCC patches <gcc-patches@gcc.gnu.org>
Subject: [Patch, fortran] [20/21] Remove coarray support in the scalarizer: Remove coarray argument
Date: Thu, 15 Sep 2011 23:10:00 -0000	[thread overview]
Message-ID: <20110915230900.28513.22165@gimli.local> (raw)
In-Reply-To: <20110915230813.28513.97419@gimli.local>

[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]

This patch, like the previous one, removes one argument from
gfc_conv_section_startstride.
We have to be more careful here as the two callers use different values
for the flag.
gfc_conv_ss_startstride calls gfc_conv_section_startstride with coarray=false.
Thus removing every !coarray condition should not be worrying.

gfc_conv_expr_descriptor on the other hand calls it with coarray=true; we have
to be more careful.

The first "if (!coarray)" is under an if (ar->dimen_type[dim] == DIMEN_VECTOR),
irrelevant for coarrays. We add an assertion that 
ar->dimen_type[dim] == DIMEN_THIS_IMAGE in gfc_conv_expr_descriptor and can
remove that condition.

The second one protects the stride initialization. As stride is
a local variable, we can remove that condition safely.
 
The third and four ones protect initialisation of info->stride[dim].
For codimensions, the stride is ignored, so we can remove that one two.
To make sure that we don't add unnecessary (and possibly costly) stride
evaluation code, that is the (stride == NULL) branch is taken, we add an
assertion in gfc_conv_expr_descriptor to check that ar->stride[dim] == NULL.
Then we can remove the flag.

OK?

[-- Attachment #2: no_coarray_in_scalarizer-20.CL --]
[-- Type: text/plain, Size: 295 bytes --]

2011-09-14  Mikael Morin  <mikael.morin@sfr.fr>

	* trans-array.c (gfc_conv_section_startstride): Remove coarray argument.
	Remove conditions on coarray.
	(gfc_conv_ss_startstride): Update call to gfc_conv_section_startstride.
	(gfc_conv_expr_descriptor): Ditto. Add assertions before the call.

[-- Attachment #3: no_coarray_in_scalarizer-20.diff --]
[-- Type: text/x-diff, Size: 2647 bytes --]

diff --git a/trans-array.c b/trans-array.c
index 95ebf6c..a034886 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -3200,8 +3200,7 @@ evaluate_bound (stmtblock_t *block, tree *bounds, gfc_expr ** values,
 /* Calculate the lower bound of an array section.  */
 
 static void
-gfc_conv_section_startstride (gfc_loopinfo * loop, gfc_ss * ss, int dim,
-			      bool coarray)
+gfc_conv_section_startstride (gfc_loopinfo * loop, gfc_ss * ss, int dim)
 {
   gfc_expr *stride = NULL;
   tree desc;
@@ -3219,16 +3218,14 @@ gfc_conv_section_startstride (gfc_loopinfo * loop, gfc_ss * ss, int dim,
       /* We use a zero-based index to access the vector.  */
       info->start[dim] = gfc_index_zero_node;
       info->end[dim] = NULL;
-      if (!coarray)
-	info->stride[dim] = gfc_index_one_node;
+      info->stride[dim] = gfc_index_one_node;
       return;
     }
 
   gcc_assert (ar->dimen_type[dim] == DIMEN_RANGE
 	      || ar->dimen_type[dim] == DIMEN_THIS_IMAGE);
   desc = info->descriptor;
-  if (!coarray)
-    stride = ar->stride[dim];
+  stride = ar->stride[dim];
 
   /* Calculate the start of the range.  For vector subscripts this will
      be the range of the vector.  */
@@ -3240,9 +3237,9 @@ gfc_conv_section_startstride (gfc_loopinfo * loop, gfc_ss * ss, int dim,
   evaluate_bound (&loop->pre, info->end, ar->end, desc, dim, false);
 
   /* Calculate the stride.  */
-  if (!coarray && stride == NULL)
+  if (stride == NULL)
     info->stride[dim] = gfc_index_one_node;
-  else if (!coarray)
+  else
     {
       gfc_init_se (&se, NULL);
       gfc_conv_expr_type (&se, stride, gfc_array_index_type);
@@ -3319,8 +3316,7 @@ done:
 	  gfc_conv_ss_descriptor (&loop->pre, ss, !loop->array_parameter);
 
 	  for (n = 0; n < ss->data.info.dimen; n++)
-	    gfc_conv_section_startstride (loop, ss, ss->data.info.dim[n],
-					  false);
+	    gfc_conv_section_startstride (loop, ss, ss->data.info.dim[n]);
 	  break;
 
 	case GFC_SS_INTRINSIC:
@@ -5975,7 +5971,14 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
 	  for (n = ss->data.info.dimen; n < ss->data.info.dimen + codim - 1;
 	       n++)
 	    {
-	      gfc_conv_section_startstride (&loop, ss, n, true);
+	      /* Make sure we are not lost somehow.  */
+	      gcc_assert (info->ref->u.ar.dimen_type[n] == DIMEN_THIS_IMAGE);
+
+	      /* Make sure the call to gfc_conv_section_startstride won't 
+	         generate unnecessary code to calculate stride.  */
+	      gcc_assert (info->ref->u.ar.stride[n] == NULL);
+
+	      gfc_conv_section_startstride (&loop, ss, n);
 	      loop.from[n] = info->start[n];
 	      loop.to[n]   = info->end[n];
 	    }

  parent reply	other threads:[~2011-09-15 23:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-15 23:09 [Patch, fortran] [00/21] Remove coarray support in the scalarizer Mikael Morin
2011-09-15 23:09 ` [Patch, fortran] [02/21] Remove coarray support in the scalarizer: Move coarray resolution code around Mikael Morin
2011-09-15 23:09 ` [Patch, fortran] [01/21] Remove coarray support in the scalarizer: Remove is_coarray Mikael Morin
2011-09-15 23:09 ` [Patch, fortran] [10/21] Remove coarray support in the scalarizer: Factor bound evaluation Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [17/21] Remove coarray support in the scalarizer: Remove gfc_ss::dimen field Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [08/21] Remove coarray support in the scalarizer: Factor array ref references Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [09/21] Remove coarray support in the scalarizer: Accept coarray dimensions in gfc_conv_section_startstride Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [21/21] Remove coarray support in the scalarizer: Final cleanup Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [16/21] Remove coarray support in the scalarizer: Remove gfc_loopinfo::codimen Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [05/21] Remove coarray support in the scalarizer: Calculate codim earlier Mikael Morin
2011-09-15 23:10 ` Mikael Morin [this message]
2011-09-15 23:10 ` [Patch, fortran] [07/21] Remove coarray support in the scalarizer: Use codim as argument gfc_get_array_type_bounds Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [19/21] Remove coarray support in the scalarizer: Remove coarray_last argument Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [06/21] Remove coarray support in the scalarizer: Request coarray for an actual arg associed with a coarray dummy Mikael Morin
2011-10-02 16:35   ` Tobias Burnus
2011-09-15 23:10 ` [Patch, fortran] [04/21] Remove coarray support in the scalarizer: Fix gfc_get_corank Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [14/21] Remove coarray support in the scalarizer: Fix full array dimension type Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [13/21] Remove coarray support in the scalarizer: Add specific walk_coarray function Mikael Morin
2011-09-15 23:10 ` [Patch, fortran] [03/21] Remove coarray support in the scalarizer: Simplify coarray descriptor setup Mikael Morin
2011-09-16  0:43 ` [Patch, fortran] [12/21] Remove coarray support in the scalarizer: Get cobounds without the scalarizer Mikael Morin
2011-09-16  5:25 ` [Patch, fortran] [15/21] Remove coarray support in the scalarizer: Remove gfc_ss::data::temp_ss::codimen field Mikael Morin
2011-09-16  5:47 ` [Patch, fortran] [11/21] Remove coarray support in the scalarizer: Support 0-rank loop in gfc_conv_ss_startstride Mikael Morin
2011-09-16  6:18 ` [Patch, fortran] [18/21] Remove coarray support in the scalarizer: Cleanup gfc_walk_variable_expr Mikael Morin
2011-09-23  7:36 ` [Patch, fortran] [00/21] Remove coarray support in the scalarizer Steve Kargl
2011-09-30 18:18 ` Steve Kargl
2011-10-07 21:14   ` Commit revisions (was: Re: [Patch, fortran] [00/21] Remove coarray support in the scalarizer) Mikael Morin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110915230900.28513.22165@gimli.local \
    --to=mikael.morin@sfr.fr \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).