public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: Sandra Loosemore <sandra@codesourcery.com>,
	"fortran@gcc.gnu.org" <fortran@gcc.gnu.org>
Cc: Tobias Burnus <tobias@codesourcery.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fortran: fix PR103390, ICE in gimplification
Date: Sun, 2 Jan 2022 21:04:48 +0100	[thread overview]
Message-ID: <71a7428d-6558-0b24-ea01-ad395adf3b99@gmx.de> (raw)
Message-ID: <20220102200448.CMSubEpilbqPV7JRXgZgB8LFKCb7ZD6F3uDjTb9hyxE@z> (raw)
In-Reply-To: <8f3ff38c-5469-9811-3466-b12ad294df09@codesourcery.com>

Hi Sandra,

Am 02.01.22 um 19:32 schrieb Sandra Loosemore:
> This patch is for PR103390.  For background on this issue, the Fortran
> standard requires that, when passing a non-contiguous array from Fortran
> to a BIND(C) function with the CONTIGUOUS attribute on the corresponding
> dummy argument, the compiler has to arrange for it to be copied to/from
> a contiguous temporary.  The ICE was happening because the front end was
> attempting to copy out to an array-valued expression that isn't an
> lvalue, and producing invalid code.
>
> I poked around at several related examples (included as test cases in
> the patch) and realized that it should not be doing any copying at all
> here, since the expression result already was being put in a contiguous
> temporary.  And, besides the invalid code on copy-out, in some cases it
> was generating multiple copies of the code to compute the expression on
> copy-in.  :-S
>
> Both parts of the patch seem to be necessary to fix all the test cases.
> Tobias pointed me in this direction when I discussed it with him a few
> weeks ago so I hope I got it right.
>
> OK to check in?  It regression-tests fine on x86_64.

LGTM.

There are a few really minor things to improve:

+	/* TRANPOSE is the only intrinsic that may return a

s/TRANPOSE/TRANSPOSE/

+! We only expect one loop before the call, to fill in the contigous

s/contigous/contiguous/

+! { dg-final { scan-tree-dump-times "contiguous\\.\[0-9\]+" 0
"original" } }

There is a shorter, slightly shorter form for absence of a pattern:

! { dg-final { scan-tree-dump-not "contiguous\\.\[0-9\]+" "original" } }

> -Sandra

Thanks for the patch!

  reply	other threads:[~2022-01-02 20:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-02 18:32 Sandra Loosemore
2022-01-02 20:04 ` Harald Anlauf [this message]
2022-01-02 20:04   ` Harald Anlauf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=71a7428d-6558-0b24-ea01-ad395adf3b99@gmx.de \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sandra@codesourcery.com \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).