* [Patch, fortran] Simplify lbound for array subcomponents
@ 2015-04-27 11:18 Mikael Morin
2015-05-01 7:27 ` Thomas Koenig
0 siblings, 1 reply; 2+ messages in thread
From: Mikael Morin @ 2015-04-27 11:18 UTC (permalink / raw)
To: gcc-patches, gfortran
[-- Attachment #1: Type: text/plain, Size: 223 bytes --]
Hello,
while reviewing Thomas' bound simplification patch, I noticed that the
{l,u}bound simplification code wasn't handling array subcomponents.
Fixed by the attached patch, regression tested. OK for trunk?
Mikael
[-- Attachment #2: bound_simplify.CL --]
[-- Type: text/plain, Size: 365 bytes --]
2015-04-27 Mikael Morin <mikael@gcc.gnu.org>
* simplify.c (simplify_bound_dim): Tighten the check for array fullness
by also checking for absence of subreference.
(simplify_bound): Don't skip simplification if the array
has subreferences.
(simplify_cobound): Same.
2015-04-27 Mikael Morin <mikael@gcc.gnu.org>
* gfortran.dg/bound_simplify_4.f90: New.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: bound_simplify.diff --]
[-- Type: text/x-patch; name="bound_simplify.diff", Size: 1178 bytes --]
Index: simplify.c
===================================================================
--- simplify.c (révision 221972)
+++ simplify.c (copie de travail)
@@ -3338,7 +3338,7 @@ simplify_bound_dim (gfc_expr *array, gfc_expr *kin
result = gfc_get_constant_expr (BT_INTEGER, k, &array->where);
/* Then, we need to know the extent of the given dimension. */
- if (coarray || ref->u.ar.type == AR_FULL)
+ if (coarray || (ref->u.ar.type == AR_FULL && !ref->next))
{
l = as->lower[d-1];
u = as->upper[d-1];
@@ -3417,11 +3417,8 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gf
case AR_FULL:
/* We're done because 'as' has already been set in the
previous iteration. */
- if (!ref->next)
- goto done;
+ goto done;
- /* Fall through. */
-
case AR_UNKNOWN:
return NULL;
@@ -3556,11 +3553,8 @@ simplify_cobound (gfc_expr *array, gfc_expr *dim,
case AR_FULL:
/* We're done because 'as' has already been set in the
previous iteration. */
- if (!ref->next)
- goto done;
+ goto done;
- /* Fall through. */
-
case AR_UNKNOWN:
return NULL;
[-- Attachment #4: bound_simplification_4.f90 --]
[-- Type: text/x-fortran, Size: 965 bytes --]
! { dg-do run }
! { dg-additional-options "-fcoarray=single -fdump-tree-original" }
!
! Check that {L,U}{,CO}BOUND intrinsics are properly simplified.
!
type :: t
integer :: c
end type t
type(t) :: d(3:8) = t(7)
type(t) :: e[5:9,-1:*]
if (lbound(d, 1) /= 3) call abort
if (lbound(d(3:5), 1) /= 1) call abort
if (lbound(d%c, 1) /= 1) call abort
if (ubound(d, 1) /= 8) call abort
if (ubound(d(3:5), 1) /= 3) call abort
if (ubound(d%c, 1) /= 6) call abort
if (lcobound(e, 1) /= 5) call abort
if (lcobound(e%c, 1) /= 5) call abort
if (lcobound(e, 2) /= -1) call abort
if (lcobound(e%c, 2) /= -1) call abort
if (ucobound(e, 1) /= 9) call abort
if (ucobound(e%c, 1) /= 9) call abort
! no simplification for ucobound(e{,%c}, dim=2)
end
! { dg-final { scan-tree-dump-not "bound" "original" } }
! { dg-final { scan-tree-dump-not "abort" "original" } }
! { dg-final { cleanup-tree-dump "original" } }
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch, fortran] Simplify lbound for array subcomponents
2015-04-27 11:18 [Patch, fortran] Simplify lbound for array subcomponents Mikael Morin
@ 2015-05-01 7:27 ` Thomas Koenig
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2015-05-01 7:27 UTC (permalink / raw)
To: Mikael Morin, gcc-patches, gfortran
Am 27.04.2015 um 13:17 schrieb Mikael Morin:
> Hello,
>
> while reviewing Thomas' bound simplification patch, I noticed that the
> {l,u}bound simplification code wasn't handling array subcomponents.
> Fixed by the attached patch, regression tested. OK for trunk?
Hi Mikael,
the patch is OK. Thanks!
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-01 7:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-27 11:18 [Patch, fortran] Simplify lbound for array subcomponents Mikael Morin
2015-05-01 7:27 ` Thomas Koenig
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).