diff mbox

[fortran] Handle missing vs. 1 strides

Message ID 1281508322.3506.4.camel@linux-fd1f.site
State New
Headers show

Commit Message

Thomas Koenig Aug. 11, 2010, 6:32 a.m. UTC
Hello world,

another patch, pretty self-explanatory.

I won't have time to commit this until the end of August, so if this is
approved, then if someone feels like it, please feel free to commit.

OK for trunk?

	Thomas

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

	PR fortran/45159
	* dependency.c (check_section_vs_section):  Single test for
	identical strides which takes into account that only one
	of the strides may be NULL.

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

	PR fortran/45159
	* gfortran.dg/dependency_33.f90:  New test.

Comments

Tobias Burnus Aug. 13, 2010, 10:21 p.m. UTC | #1
Thomas Koenig:
> I won't have time to commit this until the end of August, so if this is
> approved, then if someone feels like it, please feel free to commit.
>
> OK for trunk?

OK. Thanks for the patch - if I won't forget, I will commit it in the 
next days.

Tobias

> 2010-08-11  Thomas Koenig<tkoenig@gcc.gnu.org>
>
> 	PR fortran/45159
> 	* dependency.c (check_section_vs_section):  Single test for
> 	identical strides which takes into account that only one
> 	of the strides may be NULL.
>
> 2010-08-11  Thomas Koenig<tkoenig@gcc.gnu.org>
>
> 	PR fortran/45159
> 	* gfortran.dg/dependency_33.f90:  New test.
>
diff mbox

Patch

Index: dependency.c
===================================================================
--- dependency.c	(Revision 163040)
+++ dependency.c	(Arbeitskopie)
@@ -1023,6 +1023,7 @@  check_section_vs_section (gfc_array_ref *l_ar, gfc
   gfc_expr *r_lower;
   gfc_expr *r_upper;
   int r_dir;
+  bool identical_strides;
 
   /* If they are the same range, return without more ado.  */
   if (gfc_is_same_range (l_ar, r_ar, n, 0))
@@ -1076,6 +1077,23 @@  check_section_vs_section (gfc_array_ref *l_ar, gfc
   if (l_dir == 0 || r_dir == 0)
     return GFC_DEP_OVERLAP;
 
+  /* Determine if the strides are equal.  */
+
+  if (l_stride)
+    {
+      if (r_stride)
+	identical_strides = gfc_dep_compare_expr (l_stride, r_stride) == 0;
+      else
+	identical_strides = gfc_expr_is_one (l_stride, 0) == 1;
+    }
+  else
+    {
+      if (r_stride)
+	identical_strides = gfc_expr_is_one (r_stride, 0) == 1;
+      else
+	identical_strides = true;
+    }
+
   /* Determine LHS upper and lower bounds.  */
   if (l_dir == 1)
     {
@@ -1175,12 +1193,8 @@  check_section_vs_section (gfc_array_ref *l_ar, gfc
       && l_start && r_start && gfc_dep_compare_expr (l_start, r_start) == -1
       && l_end && r_end && gfc_dep_compare_expr (l_end, r_end) == -1)
     {
-      /* Check that the strides are the same.  */
-      if (!l_stride && !r_stride)
+      if (identical_strides)
 	return GFC_DEP_FORWARD;
-      if (l_stride && r_stride
-	  && gfc_dep_compare_expr (l_stride, r_stride) == 0)
-	return GFC_DEP_FORWARD;
     }
 
   /* Check for forward dependencies x:y:-1 vs. x-1:z:-1.  */
@@ -1188,20 +1202,12 @@  check_section_vs_section (gfc_array_ref *l_ar, gfc
       && l_start && r_start && gfc_dep_compare_expr (l_start, r_start) == 1
       && l_end && r_end && gfc_dep_compare_expr (l_end, r_end) == 1)
     {
-      /* Check that the strides are the same.  */
-      if (!l_stride && !r_stride)
+      if (identical_strides)
 	return GFC_DEP_FORWARD;
-      if (l_stride && r_stride
-	  && gfc_dep_compare_expr (l_stride, r_stride) == 0)
-	return GFC_DEP_FORWARD;
     }
 
 
-  /*  Are the strides the same?  */
-  if ((!l_stride && !r_stride)
-	||
-      (l_stride && r_stride
-	&& gfc_dep_compare_expr (l_stride, r_stride) == 0))
+  if (identical_strides)
     {
 
       if (l_start && IS_ARRAY_EXPLICIT (l_ar->as))