]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/45159 (Unnecessary temporaries)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 3 Aug 2010 22:02:30 +0000 (22:02 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 3 Aug 2010 22:02:30 +0000 (22:02 +0000)
2010-08-03  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/45159
* dependency.c (gfc_deb_compare_expr):  Remove any integer
conversion functions to larger types from both arguments.
Remove handling these functions futher down.

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

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

From-SVN: r162848

gcc/fortran/ChangeLog
gcc/fortran/dependency.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/dependency_30.f90 [new file with mode: 0644]

index 23c0a1ef1ff30bd685f05aa9ce9fd416f46f7a58..a426d83e84cfbd111a731bf9333a78261d9b8412 100644 (file)
@@ -1,3 +1,10 @@
+2010-08-03  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/45159
+       * dependency.c (gfc_deb_compare_expr):  Remove any integer
+       conversion functions to larger types from both arguments.
+       Remove handling these functions futher down.
+
 2010-08-03  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/44584
index 1eae1ebaa810a8558f0164f06c3b0f1a9b71976a..90b2d679ec929d46f9a4840679d7da43adb37513 100644 (file)
@@ -180,7 +180,45 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
   gfc_actual_arglist *args1;
   gfc_actual_arglist *args2;
   int i;
+  gfc_expr *n1, *n2;
 
+  n1 = NULL;
+  n2 = NULL;
+
+  /* Remove any integer conversion functions to larger types.  */
+  if (e1->expr_type == EXPR_FUNCTION && e1->value.function.isym
+      && e1->value.function.isym->id == GFC_ISYM_CONVERSION
+      && e1->ts.type == BT_INTEGER)
+    {
+      args1 = e1->value.function.actual;
+      if (args1->expr->ts.type == BT_INTEGER
+         && e1->ts.kind > args1->expr->ts.kind)
+       n1 = args1->expr;
+    }
+
+  if (e2->expr_type == EXPR_FUNCTION && e2->value.function.isym
+      && e2->value.function.isym->id == GFC_ISYM_CONVERSION
+      && e2->ts.type == BT_INTEGER)
+    {
+      args2 = e2->value.function.actual;
+      if (args2->expr->ts.type == BT_INTEGER
+         && e2->ts.kind > args2->expr->ts.kind)
+       n2 = args2->expr;
+    }
+
+  if (n1 != NULL)
+    {
+      if (n2 != NULL)
+       return gfc_dep_compare_expr (n1, n2);
+      else
+       return gfc_dep_compare_expr (n1, e2);
+    }
+  else
+    {
+      if (n2 != NULL)
+       return gfc_dep_compare_expr (e1, n2);
+    }
+  
   if (e1->expr_type == EXPR_OP
       && (e1->value.op.op == INTRINSIC_UPLUS
          || e1->value.op.op == INTRINSIC_PARENTHESES))
@@ -328,20 +366,6 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2)
         argument lists.  */
       switch (e1->value.function.isym->id)
        {
-       case GFC_ISYM_CONVERSION:
-         /* Handle integer extensions specially, as __convert_i4_i8
-            is not only "constant" but also "unary" and "increasing".  */
-         if (args1 && !args1->next
-             && args2 && !args2->next
-             && e1->ts.type == BT_INTEGER
-             && args1->expr->ts.type == BT_INTEGER
-             && e1->ts.kind > args1->expr->ts.kind
-             && e2->ts.type == e1->ts.type
-             && e2->ts.kind == e1->ts.kind
-             && args2->expr->ts.type == args1->expr->ts.type
-             && args2->expr->ts.kind == args2->expr->ts.kind)
-           return gfc_dep_compare_expr (args1->expr, args2->expr);
-         break;
 
        case GFC_ISYM_REAL:
        case GFC_ISYM_LOGICAL:
index 8fbbb522c22465fdf58c488963c24b54137eb3bc..960b7fe807d33b13f09cb05c872c25183c2e0138 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-03  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/45159
+       * gfortran.dg/dependency_30.f90:  New test.
+
 2010-08-03  Jan Hubicka  <jh@suse.cz>
 
        * gcc.c-torture/compile/pr45085.c: New testcase.
diff --git a/gcc/testsuite/gfortran.dg/dependency_30.f90 b/gcc/testsuite/gfortran.dg/dependency_30.f90
new file mode 100644 (file)
index 0000000..575dbeb
--- /dev/null
@@ -0,0 +1,9 @@
+! { do-do compile }
+! { dg-options "-Warray-temporaries" }
+! PR 45159 - make sure no temporary is created for this.
+subroutine foo(a,b,i,j,k,n)
+  implicit none
+  integer, intent(in) :: i, j, k, n
+  real, dimension(n) :: a,b
+  a(k:i-1) = a(i:j)
+end subroutine foo