* [patch, fortran] Fix handling of assumed-size arrays in inline matmul
@ 2018-02-12 10:46 Thomas Koenig
2018-02-17 14:22 ` *ping* " Thomas Koenig
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2018-02-12 10:46 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 594 bytes --]
Hello world,
the attached patch fixes a regression where a rejects-valid would
be issued.
OK for the affected branches, trunk and gcc-7?
Regards
Thomas
2018-02-12 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84270
* frontend-passes (scalarized_expr): If the expression
is an assumed size array, leave in the last reference
and pass AR_SECTION instead of AR_FULL to gfc_resolve
in order to avoid an error.
2018-02-12 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/84270
* gfortran.dg/inline_matmul_22.f90: New test.
[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 940 bytes --]
Index: frontend-passes.c
===================================================================
--- frontend-passes.c (Revision 257347)
+++ frontend-passes.c (Arbeitskopie)
@@ -3567,11 +3567,27 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index,
is the lbound of a full ref. */
int j;
gfc_array_ref *ar;
+ int to;
ar = &ref->u.ar;
- ar->type = AR_FULL;
- for (j = 0; j < ar->dimen; j++)
+
+ /* For assumed size, we need to keep around the final
+ reference in order not to get an error on resolution
+ below, and we cannot use AR_FULL. */
+
+ if (ar->as->type == AS_ASSUMED_SIZE)
{
+ ar->type = AR_SECTION;
+ to = ar->dimen - 1;
+ }
+ else
+ {
+ to = ar->dimen;
+ ar->type = AR_FULL;
+ }
+
+ for (j = 0; j < to; j++)
+ {
gfc_free_expr (ar->start[j]);
ar->start[j] = NULL;
gfc_free_expr (ar->end[j]);
[-- Attachment #3: inline_matmul_22.f90 --]
[-- Type: text/x-fortran, Size: 1112 bytes --]
! { dg-do compile }
! { dg-additional-options "-ffrontend-optimize" }
! PR 84270 - this used to be rejected.
! Test case by Michael Weinert
module fp_precision
integer, parameter :: fp = selected_real_kind(13)
end module fp_precision
subroutine lhcal(nrot,orth,ngpts,vgauss,vr_0)
use fp_precision ! floating point precision
implicit none
!---> rotation matrices and rotations (input)
integer, intent(in) :: nrot
! real(kind=fp), intent(in) :: orth(3,3,nrot) ! fine at all -O
real(kind=fp), intent(in) :: orth(3,3,*)
!---> gaussian integration points
integer, intent(in) :: ngpts
real(kind=fp), intent(in) :: vgauss(3,*)
!---> output results
real(kind=fp), intent(out) :: vr_0(3)
real(kind=fp) :: v(3),vr(3)
integer :: n,nn
vr_0 = 0
do nn=1,ngpts
v(:) = vgauss(:,nn)
!---> apply rotations
do n=2,nrot
vr = matmul( orth(:,:,n), v )
vr_0 = vr_0 + vr
enddo
enddo
return
end subroutine lhcal
^ permalink raw reply [flat|nested] 3+ messages in thread
* *ping* [patch, fortran] Fix handling of assumed-size arrays in inline matmul
2018-02-12 10:46 [patch, fortran] Fix handling of assumed-size arrays in inline matmul Thomas Koenig
@ 2018-02-17 14:22 ` Thomas Koenig
2018-02-17 15:27 ` Jerry DeLisle
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2018-02-17 14:22 UTC (permalink / raw)
To: fortran, gcc-patches
Am 12.02.2018 um 11:46 schrieb Thomas Koenig:
> Hello world,
>
> the attached patch fixes a regression where a rejects-valid would
> be issued.
>
> OK for the affected branches, trunk and gcc-7?
PING ** (5.D0/7.D0) ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: *ping* [patch, fortran] Fix handling of assumed-size arrays in inline matmul
2018-02-17 14:22 ` *ping* " Thomas Koenig
@ 2018-02-17 15:27 ` Jerry DeLisle
0 siblings, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2018-02-17 15:27 UTC (permalink / raw)
To: Thomas Koenig, fortran, gcc-patches
On 02/17/2018 06:22 AM, Thomas Koenig wrote:
> Am 12.02.2018 um 11:46 schrieb Thomas Koenig:
>> Hello world,
>>
>> the attached patch fixes a regression where a rejects-valid would
>> be issued.
>>
>> OK for the affected branches, trunk and gcc-7?
>
> PING ** (5.D0/7.D0) ?
>
>
Yes, OK
Jerry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-17 15:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-12 10:46 [patch, fortran] Fix handling of assumed-size arrays in inline matmul Thomas Koenig
2018-02-17 14:22 ` *ping* " Thomas Koenig
2018-02-17 15:27 ` Jerry DeLisle
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).