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]

Re: [patch, Fortran] Fix some string temporaries


Hello,

Le 16/07/2016 à 15:38, Thomas Koenig a écrit :
Hello world,

this fixes PR 71902. The recent fix for PR 71783 introduced a
performance and code size regression a string temporary was created for
the test case when it was not actually needed.

I also took the opportunity of renaming the misnomed temporary
variable.

Regression-tested.

OK for trunk?

Do we actually want to backport this? Technically, it is a regression,
but people are not likely to notice much.

It is not an ICE, neither a code correctness issue as far as I can see, so I would rather not backport.

comments below.

p3.diff

Index: dependency.c
===================================================================
--- dependency.c	(Revision 238223)
+++ dependency.c	(Arbeitskopie)
@@ -54,6 +54,8 @@ enum gfc_dependency
 static gfc_dependency check_section_vs_section (gfc_array_ref *,
 						gfc_array_ref *, int);

+static gfc_dependency dep_ref (gfc_ref *, gfc_ref *, gfc_reverse *);
+
 /* Returns 1 if the expr is an integer constant value 1, 0 if it is not or
    def if the value could not be determined.  */

@@ -1316,14 +1318,34 @@ gfc_check_dependency (gfc_expr *expr1, gfc_expr *e
 	  return 0;
 	}

-      if (identical)
-	return 1;
-
       /* Identical and disjoint ranges return 0,
 	 overlapping ranges return 1.  */
       if (expr1->ref && expr2->ref)
-	return gfc_dep_resolver (expr1->ref, expr2->ref, NULL);
+	{
+	  gfc_dependency dep;
+	  dep = dep_ref (expr1->ref, expr2->ref, NULL);
+	  switch (dep)
+	    {
+	    case GFC_DEP_EQUAL:
+	      return identical;

+	    case GFC_DEP_FORWARD:
+	      return 0;
+
This is doubtfull, but not worse than before I guess.

+	    case GFC_DEP_BACKWARD:
+	      return 1;
+
+	    case GFC_DEP_OVERLAP:
+	      return 1;
+
+	    case GFC_DEP_NODEP:
+	      return 0;
+
+	    case GFC_DEP_ERROR:
+	      return 0;
Can we put a gcc_unreachable here instead?

+	    }
+	}
+
       return 1;

     case EXPR_FUNCTION:
@@ -2052,11 +2074,44 @@ ref_same_as_full_array (gfc_ref *full_ref, gfc_ref
    	2 : array references are overlapping but reversal of one or
 	    more dimensions will clear the dependency.
    	1 : array references are overlapping.
-   	0 : array references are identical or not overlapping.  */
+   	0 : array references are identical or can be handled in a forward loop.  */

 int
 gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse)
 {
+  enum gfc_dependency dep;
+  dep = dep_ref (lref, rref, reverse);
+  switch (dep)
+    {
+    case GFC_DEP_EQUAL:
+      return 0;
+
+    case GFC_DEP_FORWARD:
+      return 0;
+
+    case GFC_DEP_BACKWARD:
+      return 2;
+
+    case GFC_DEP_OVERLAP:
+      return 1;
+
+    case GFC_DEP_NODEP:
+      return 0;
+
+    case GFC_DEP_ERROR:
+      return 0;
+
same here, make it unreachable please.

OK with this and the other unreachable change above.

Thanks,
Mikael

+    default:
+      gcc_unreachable();
+    }
+}
+
+/* Compare two references, returning an enum gfc_dependency depending on the
+   "worst" type of dependency found.  */
+
+static gfc_dependency
+dep_ref (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse)
+{
   int n;
   int m;
   gfc_dependency fin_dep;


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