diff mbox

[fortran,7/11] Inline transpose part 1

Message ID 4C8257E1.3010400@sfr.fr
State New
Headers show

Commit Message

Mikael Morin Sept. 4, 2010, 2:29 p.m. UTC
Two identical array refs need a temporary if one is transposed w.r.t the 
other.
OK for trunk?
2010-09-03  Mikael Morin  <mikael@gcc.gnu.org>

	* trans-array.c (gfc_conv_resolve_dependencies): Handle same-array
	transposed references.
diff mbox

Patch

diff --git a/trans-array.c b/trans-array.c
index 148bf6b..371654c 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -3516,6 +3516,7 @@  gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest,
   gfc_ref *lref;
   gfc_ref *rref;
   int nDepend = 0;
+  int i, j;
 
   loop->temp_ss = NULL;
 
@@ -3542,6 +3543,17 @@  gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest,
 
 	  if (nDepend == 1)
 	    break;
+
+	  for (i = 0; i < dest->data.info.dimen; i++)
+	    for (j = 0; j < ss->data.info.dimen; j++)
+	      if (i != j
+		  && dest->data.info.dim[i] == ss->data.info.dim[j])
+		{
+		  /* If we don't access array elements in the same order,
+		     there is a dependency.  */
+		  nDepend = 1;
+		  goto temporary;
+		}
 #if 0
 	  /* TODO : loop shifting.  */
 	  if (nDepend == 1)
@@ -3580,6 +3592,8 @@  gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest,
 	}
     }
 
+temporary:
+
   if (nDepend == 1)
     {
       tree base_type = gfc_typenode_for_spec (&dest->expr->ts);