Patchwork [fortran] Further dependency improvements

login
register
mail settings
Submitter Thomas Koenig
Date Aug. 5, 2010, 7:13 a.m.
Message ID <1280992388.4643.13.camel@linux-fd1f.site>
Download mbox | patch
Permalink /patch/60928/
State New
Headers show

Comments

Thomas Koenig - Aug. 5, 2010, 7:13 a.m.
Hello world,

this patch handles another dependency checking improvement.
Regression-tested.

OK for trunk?

	Thomas

2010-08-05  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/45159
	* dependency.c (check_section_vs_section):  Handle cases where
	the start expression coincides with the lower or upper
	bound of the array.

2010-08-05  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/45159
	* gfortran.dg/dependency_31.f90:  New test.
Steven Bosscher - Aug. 5, 2010, 7:35 a.m.
On Thu, Aug 5, 2010 at 9:13 AM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hello world,
>
> this patch handles another dependency checking improvement.
> Regression-tested.
>
> OK for trunk?
>
>        Thomas
>
> 2010-08-05  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>        PR fortran/45159
>        * dependency.c (check_section_vs_section):  Handle cases where
>        the start expression coincides with the lower or upper
>        bound of the array.


> +      /* From here, check for backards dependencies.  */

Typo, s/backards/backwards/

Otherwise, looks like a good improvement for a common case.

Ciao!
Steven

Patch

Index: dependency.c
===================================================================
--- dependency.c	(Revision 162848)
+++ dependency.c	(Arbeitskopie)
@@ -1196,13 +1196,33 @@  check_section_vs_section (gfc_array_ref *l_ar, gfc
 	return GFC_DEP_FORWARD;
     }
 
-  /* Check for backward dependencies:
-     Are the strides the same?.  */
+
+  /*  Are the strides the same?  */
   if ((!l_stride && !r_stride)
 	||
       (l_stride && r_stride
 	&& gfc_dep_compare_expr (l_stride, r_stride) == 0))
     {
+
+      if (l_start && IS_ARRAY_EXPLICIT (l_ar->as))
+	{
+
+	  /* Check for a(low:y:s) vs. a(z:a:s) where a has a lower bound
+	     of low, which is always at least a forward dependence.  */
+
+	  if (r_dir == 1
+	      && gfc_dep_compare_expr (l_start, l_ar->as->lower[n]) == 0)
+	    return GFC_DEP_FORWARD;
+
+	  /* Check for a(high:y:-s) vs. a(z:a:-s) where a has a higher bound
+	     of high, which is always at least a forward dependence.  */
+
+	  if (r_dir == -1
+	      && gfc_dep_compare_expr (l_start, l_ar->as->upper[n]) == 0)
+	    return GFC_DEP_FORWARD;
+	}
+
+      /* From here, check for backards dependencies.  */
       /* x:y vs. x+1:z.  */
       if (l_dir == 1 && r_dir == 1
 	    && l_start && r_start