re PR fortran/57992 (Pointless packing of contiguous arrays for simply contiguous...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 13 Jan 2019 14:57:39 +0000 (14:57 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 13 Jan 2019 14:57:39 +0000 (14:57 +0000)
2019-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/57992
* trans-array.c (gfc_conv_array_parameter):  Do not pack/unpack
functions with contiguous results.

2019-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/59345
* gfortran.dg/internal_pack_18.f90: New test.

From-SVN: r267905

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/internal_pack_18.f90 [new file with mode: 0644]

index 82e122ed1632d75a9abc28e07ee5aa84fc582be5..ca20973bf5a231ce55d618c2e0072c5d327700dc 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/57992
+       * trans-array.c (gfc_conv_array_parameter):  Do not pack/unpack
+       functions with contiguous results.
+
 2019-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/59345
index ae597e8e4bf1f02cc734d83b0160a54e337c7e45..1814916c73d584f568c3b0569ba98804c64446bb 100644 (file)
@@ -7894,7 +7894,9 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77,
        {
          gfc_symbol *result = expr->value.function.esym->result;
          if (result->attr.dimension
-             && (result->as->type == AS_EXPLICIT || result->attr.allocatable))
+             && (result->as->type == AS_EXPLICIT
+                 || result->attr.allocatable
+                 || result->attr.contiguous))
            no_pack = 1;
        }
     }
index 10bf8bdc10761620cfa18d413c85ca9dbf4c076d..33a7f95464dc5b03f46898749e8b415a878c3ec2 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/59345
+       * gfortran.dg/internal_pack_18.f90: New test.
+
 2019-01-13  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gcc.dg/pr51628-20.c: Updated.
diff --git a/gcc/testsuite/gfortran.dg/internal_pack_18.f90 b/gcc/testsuite/gfortran.dg/internal_pack_18.f90
new file mode 100644 (file)
index 0000000..ede0691
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-original" }
+! PR 57992 - this was packed/unpacked unnecessarily.
+! Original case by Tobias Burnus.
+subroutine test
+  interface
+    function f2()
+      integer, pointer, contiguous :: f2(:)
+    end function f2
+  end interface
+
+ call bar(f2())
+end subroutine test
+! { dg-final { scan-tree-dump-not "_gfortran_internal_pack" "original" } }
+! { dg-final { scan-tree-dump-not "_gfortran_internal_unpack" "original" } }