diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2015-04-30 22:12:31 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2015-04-30 22:12:31 +0000 |
commit | 0ba691a0978c604107007a3fe1cec1dc3c577c25 (patch) | |
tree | b5190b6aac7c48a4a16f97103c82929fba8919a9 /gcc/fortran/simplify.c | |
parent | 6f3d1a5e66b208f9e6599331940ff0cc88df4aa0 (diff) | |
download | gcc-0ba691a0978c604107007a3fe1cec1dc3c577c25.zip gcc-0ba691a0978c604107007a3fe1cec1dc3c577c25.tar.gz gcc-0ba691a0978c604107007a3fe1cec1dc3c577c25.tar.bz2 |
re PR fortran/37131 (inline matmul for small matrix sizes)
2015-04-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/37131
* simplify.c (simplify_bound): Get constant lower bounds of one
from array spec for assumed and explicit shape shape arrays if
the lower bounds are indeed one.
2015-04-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/37131
* gfortran.dg/coarray_lib_this_image_2.f90: Adjust
scan pattern.
* gfortran.dg/bound_9.f90: New test case.
From-SVN: r222661
Diffstat (limited to 'gcc/fortran/simplify.c')
-rw-r--r-- | gcc/fortran/simplify.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 92b3076..f631ac8 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -3445,6 +3445,39 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper) done: + /* If the array shape is assumed shape or explicit, we can simplify lbound + to 1 if the given lower bound is one because this matches what lbound + should return for an empty array. */ + + if (!upper && as && dim && dim->expr_type == EXPR_CONSTANT + && (as->type == AS_ASSUMED_SHAPE || as->type == AS_EXPLICIT) + && ref->u.ar.type != AR_SECTION) + { + /* Watch out for allocatable or pointer dummy arrays, they can have + lower bounds that are not equal to one. */ + if (!(array->symtree && array->symtree->n.sym + && (array->symtree->n.sym->attr.allocatable + || array->symtree->n.sym->attr.pointer))) + { + unsigned long int ndim; + gfc_expr *lower, *res; + + ndim = mpz_get_si (dim->value.integer) - 1; + lower = as->lower[ndim]; + if (lower->expr_type == EXPR_CONSTANT + && mpz_cmp_si (lower->value.integer, 1) == 0) + { + res = gfc_copy_expr (lower); + if (kind) + { + int nkind = mpz_get_si (kind->value.integer); + res->ts.kind = nkind; + } + return res; + } + } + } + if (as && (as->type == AS_DEFERRED || as->type == AS_ASSUMED_SHAPE || as->type == AS_ASSUMED_RANK)) return NULL; |