[Patch, Fortran] Simplify lbound
Mikael Morin
mikael.morin@sfr.fr
Fri May 1 21:04:00 GMT 2015
Hello,
Le 30/04/2015 20:19, Mikael Morin a écrit :
>>> 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).
>>
>> Actually, no. You can have assumed-shape allocatable or pointer
>> dummy arguments which keep their original lbound; see the subroutine
>> 'bar' in the test case.
>>
>>> - 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.
>>
>> That is not part of my patch.
>>
> I'm not sure I expressed what I was asking for clearly enough.
> Anyway, I may as well submit the requested changes myself.
>
I present here the announced above follow-up change to Thomas' recent
bound simplification patch.
It basically removes the code added and tighten the condition
mentioned above, so that we don't give up too early to simplify the
lbound of an assumed shape array, and let the existing code do the
simplification.
To not regression wrt to Thomas work, I had to also adjust early
give-ups in simplify_bound_dim.
But the code has been reorganized, so that it doesn't appear clearly.
The declared bound and empty bound value have been abstracted
from the differentiated lbound/ubound specifics. Then the
simplification is applied indifferently on those abstractions.
Finally, the empty array tricks have been disabled for the CO{L,U}BOUND
intrinsics.
With these changes, Thomas' tests continue to work and one gets DIM-less
bound simplification "for free".
The testsuite adds tests for zero sized arrays and DIM-less {L,U}BOUND
calls.
I had to remove the check for absence of string "bound" in the dump:
there is code generated for assumed shape arrays that plays tricks with
bounds and contains that string, even if the code generated for the body
itself of the procedure is empty.
Regression tested on x86_64-unknown-linux-gnu. OK for trunk?
Mikael
-------------- next part --------------
2015-05-01 Mikael Morin <mikael@gcc.gnu.org>
* simplify.c (simplify_bound_dim): Don't check for emptyness
in the case of cobound simplification. Factor lower/upper
bound differenciation before the actual simplification.
(simplify_bound): Remove assumed shape specific simplification.
Don't give up early for the lbound of an assumed shape.
2015-05-01 Mikael Morin <mikael@gcc.gnu.org>
* gfortran.dg/bound_simplification_4.f90: Disable implicit typing.
Add checks for bound simplification without DIM argument.
Add checks for empty array and assumed shape bound simplification.
Remove check for absence of string "bound" in the dump.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bound_simplification_integration_full.diff
Type: text/x-patch
Size: 6476 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150501/ab080a4d/attachment.bin>
More information about the Fortran
mailing list