aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMikael Morin <mikael@gcc.gnu.org>2015-05-01 13:32:42 +0000
committerMikael Morin <mikael@gcc.gnu.org>2015-05-01 13:32:42 +0000
commit11642de8a8c04a4e9c0eeea663e53e27eae7537a (patch)
tree290809dd2859bb40c21b878fcd3db098a2f2b075 /gcc
parent50093a330f9e4d1b816f77c4ff8bb0dcfea96549 (diff)
downloadgcc-11642de8a8c04a4e9c0eeea663e53e27eae7537a.zip
gcc-11642de8a8c04a4e9c0eeea663e53e27eae7537a.tar.gz
gcc-11642de8a8c04a4e9c0eeea663e53e27eae7537a.tar.bz2
Allow bound simplification of array subreferences.
gcc/fortran/ * 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. gcc/testsuite/ * gfortran.dg/bound_simplification_4.f90: New. From-SVN: r222681
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/simplify.c12
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gfortran.dg/bound_simplification_4.f9030
4 files changed, 45 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 021d20d..fbf8f7b 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2015-05-01 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-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/37131
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index f631ac8..4ef9025 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -3338,7 +3338,7 @@ simplify_bound_dim (gfc_expr *array, gfc_expr *kind, int d, int upper,
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,10 +3417,7 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
case AR_FULL:
/* We're done because 'as' has already been set in the
previous iteration. */
- if (!ref->next)
- goto done;
-
- /* Fall through. */
+ goto done;
case AR_UNKNOWN:
return NULL;
@@ -3589,10 +3586,7 @@ simplify_cobound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
case AR_FULL:
/* We're done because 'as' has already been set in the
previous iteration. */
- if (!ref->next)
- goto done;
-
- /* Fall through. */
+ goto done;
case AR_UNKNOWN:
return NULL;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8293e8f..fb9c521 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-01 Mikael Morin <mikael@gcc.gnu.org>
+
+ * gfortran.dg/bound_simplification_4.f90: New.
+
2015-04-30 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* gcc.target/powerpc/crypto-builtin-2.c: Replace powerpc_vsx_ok
diff --git a/gcc/testsuite/gfortran.dg/bound_simplification_4.f90 b/gcc/testsuite/gfortran.dg/bound_simplification_4.f90
new file mode 100644
index 0000000..28a8d67
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/bound_simplification_4.f90
@@ -0,0 +1,30 @@
+! { 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" } }