From 8ef8fa9a4de095b17647b65b22081413d6afd171 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sun, 13 Jan 2019 14:57:39 +0000 Subject: [PATCH] re PR fortran/57992 (Pointless packing of contiguous arrays for simply contiguous functions results as actual arguments) 2019-01-13 Thomas Koenig PR fortran/57992 * trans-array.c (gfc_conv_array_parameter): Do not pack/unpack functions with contiguous results. 2019-01-13 Thomas Koenig PR fortran/59345 * gfortran.dg/internal_pack_18.f90: New test. From-SVN: r267905 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/trans-array.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/internal_pack_18.f90 | 15 +++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/internal_pack_18.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 82e122ed163..ca20973bf5a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-01-13 Thomas Koenig + + PR fortran/57992 + * trans-array.c (gfc_conv_array_parameter): Do not pack/unpack + functions with contiguous results. + 2019-01-13 Thomas Koenig PR fortran/59345 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index ae597e8e4bf..1814916c73d 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 10bf8bdc107..33a7f95464d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-13 Thomas Koenig + + PR fortran/59345 + * gfortran.dg/internal_pack_18.f90: New test. + 2019-01-13 H.J. Lu * 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 index 00000000000..ede0691bb9f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/internal_pack_18.f90 @@ -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" } } -- 2.30.2