[Patch, Fortran] Simplify lbound
Mikael Morin
mikael.morin@sfr.fr
Sat Apr 25 18:13:00 GMT 2015
Le 25/04/2015 13:33, Thomas Koenig a écrit :
> Hello world,
>
> this is a simplification for calculating the lboud of assumed-shape
> arrays - it is usually one, or whatever the user specified as
> lower bound (if constant).
>
Hello,
I've double-checked in the standard, and it seems it is not possible to
simplify after all:
If ARRAY is a whole array and either ARRAY is an assumed-size
array of rank DIM or dimension DIM of ARRAY has nonzero extent,
LBOUND (ARRAY, DIM) has a value equal to the lower bound for
subscript DIM of ARRAY. Otherwise the result value is 1.
We can't tell whether the array is zero-sized, so we can't tell the
lbound value.
As you may want to simplify in the limited scope of the matmul inlining,
I'm giving comments about the patch (otherwise you can ignore them):
- No need to check for allocatable or pointer, it should be excluded by
as->type == AS_ASSUMED_SHAPE (but does no harm either).
- Please modify the early return condition:
if (as && (as->type == AS_DEFERRED || as->type == AS_ASSUMED_SHAPE
|| as->type == AS_ASSUMED_RANK))
return NULL;
and let the existing code do the simplification work.
Or drop the lbound simplification idea, and fetch the lbound "by hand"
at matmul inline time.
Mikael
More information about the Fortran
mailing list