public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] Fix PR 66089, ICE (plus wrong code) in dependency handling
@ 2019-03-06 20:28 Thomas Koenig
  2019-03-08  8:46 ` Bernhard Reutner-Fischer
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Koenig @ 2019-03-06 20:28 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 881 bytes --]

Hello world,

the attached patch fixes a 7/8/9 regression where dependency checking
was for class arrays and a scalar value was mishandled when the
dependency happened in an elemental function.

There was an ICE for the test case which is handled by
fixing up the class refs in gfc_walk_variable_expr.
Once this was gone, a wrong-code issue appeared which was fixed
by the part in gfc_scalar_elemental_arg_saved_as_reference
(is that the longest function name in gfortran?).

Regression-tested. OK for all affected branches?

Regards

	Thomas

2019-03-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/66089
	* trans-array.c (gfc_scalar_elemental_arg_saved_as_reference):
	Return false if a scalar tempoary is needed.
	(gfc_walk_variable_expr): Fix up class refs.

2019-03-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/66089
	* gfortran.dg/dependency_53.f90: New test.

[-- Attachment #2: p2.diff --]
[-- Type: text/x-patch, Size: 783 bytes --]

Index: trans-array.c
===================================================================
--- trans-array.c	(Revision 269260)
+++ trans-array.c	(Arbeitskopie)
@@ -2699,6 +2699,9 @@ gfc_scalar_elemental_arg_saved_as_reference (gfc_s
   if (ss_info->type != GFC_SS_REFERENCE)
     return false;
 
+  if (ss_info->data.scalar.needs_temporary)
+    return false;
+
   /* If the actual argument can be absent (in other words, it can
      be a NULL reference), don't try to evaluate it; pass instead
      the reference directly.  */
@@ -10515,6 +10518,8 @@ gfc_walk_variable_expr (gfc_ss * ss, gfc_expr * ex
 {
   gfc_ref *ref;
 
+  gfc_fix_class_refs (expr);
+
   for (ref = expr->ref; ref; ref = ref->next)
     if (ref->type == REF_ARRAY && ref->u.ar.type != AR_ELEMENT)
       break;

[-- Attachment #3: dependency_53.f90 --]
[-- Type: text/x-fortran, Size: 538 bytes --]

! { dg-do run }
! PR fortran/66089 - used to ICE and, after that ICE was fixed,
! gave wrong results.
  type :: t
    integer :: c
  end type t

  class(t), dimension(:), allocatable :: b,c

  allocate (b(5), source=t(7))
  allocate(c(5), source=t(13))
  c = plus(c(1), b)
  if (any(c%c /= 20)) call abort
  c = t(13)
  c = plus(b, c(1))
  if (any(c%c /= 20)) call abort
contains

  elemental function plus(lhs, rhs)
    class(t), intent(in) :: lhs, rhs
    type(t)             :: plus
    plus%c = lhs%c + rhs%c
  end function plus

end

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, fortran] Fix PR 66089, ICE (plus wrong code) in dependency handling
  2019-03-06 20:28 [patch, fortran] Fix PR 66089, ICE (plus wrong code) in dependency handling Thomas Koenig
@ 2019-03-08  8:46 ` Bernhard Reutner-Fischer
  2019-03-08 18:19   ` Thomas Koenig
  0 siblings, 1 reply; 4+ messages in thread
From: Bernhard Reutner-Fischer @ 2019-03-08  8:46 UTC (permalink / raw)
  To: gcc-patches, Thomas Koenig, fortran, gcc-patches

On 6 March 2019 19:49:59 CET, Thomas Koenig <tkoenig@netcologne.de> wrote:
>Hello world,
>
>the attached patch fixes a 7/8/9 regression where dependency checking
>was for class arrays and a scalar value was mishandled when the
>dependency happened in an elemental function.
>
>There was an ICE for the test case which is handled by
>fixing up the class refs in gfc_walk_variable_expr.
>Once this was gone, a wrong-code issue appeared which was fixed
>by the part in gfc_scalar_elemental_arg_saved_as_reference
>(is that the longest function name in gfortran?).
>
>Regression-tested. OK for all affected branches?

Please change call abort to stop N in the test?

>	PR fortran/66089
>	* gfortran.dg/dependency_53.f90: New test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, fortran] Fix PR 66089, ICE (plus wrong code) in dependency handling
  2019-03-08  8:46 ` Bernhard Reutner-Fischer
@ 2019-03-08 18:19   ` Thomas Koenig
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Koenig @ 2019-03-08 18:19 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer, gcc-patches, fortran

Am 08.03.19 um 08:04 schrieb Bernhard Reutner-Fischer:
> Please change call abort to stop N in the test?

Done.

Anything else?  OK for trunk?

Regards

	Thomas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, fortran] Fix PR 66089, ICE (plus wrong code) in dependency handling
@ 2019-03-11  9:22 Dominique d'Humières
  0 siblings, 0 replies; 4+ messages in thread
From: Dominique d'Humières @ 2019-03-11  9:22 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: gfortran, gcc-patches

Hi Thomas,

> Anything else? …

Yes, the tests gfortran.dg/assumed_type_2.f90 and gfortran.dg/no_arg_check_2.f90 fail:

FAIL: gfortran.dg/assumed_type_2.f90   -O   scan-tree-dump-times original "sub_array_assumed \\\\(D" 3 (found 4 times)
FAIL: gfortran.dg/assumed_type_2.f90   -O   scan-tree-dump-times original "sub_array_assumed \\\\(\\\\(struct t1.0:. .\\\\) array_class_t1_ptr._data.data\\\\);" 1 (found 0 times)

FAIL: gfortran.dg/no_arg_check_2.f90   -O   scan-tree-dump-times original "sub_array_assumed \\\\(D" 3 (found 4 times)
FAIL: gfortran.dg/no_arg_check_2.f90   -O   scan-tree-dump-times original "sub_array_assumed \\\\(\\\\(struct t1.0:. .\\\\) array_class_t1_ptr._data.data\\\\);" 1 (found 0 times)

TIA

Dominique

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-11  9:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-06 20:28 [patch, fortran] Fix PR 66089, ICE (plus wrong code) in dependency handling Thomas Koenig
2019-03-08  8:46 ` Bernhard Reutner-Fischer
2019-03-08 18:19   ` Thomas Koenig
2019-03-11  9:22 Dominique d'Humières

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).