[Fortran] Improved dependency analysis of pointer variables
Paul Thomas
paulthomas2@wanadoo.fr
Thu Mar 16 19:10:00 GMT 2006
Tobias,
>Quoting Roger Sayle <roger@eyesopen.com>:
>
>
>>Ok, I've found the bug in gfc_are_equivalenced_arrays. Its on line
>>450 of dependency.c in the following test:
>>
>> if (fl1 && fl2 && (fl1->offset > fl2->offset))
>> return 1;
>>
>>For the test cases above, the offset of both "x" and "i" are zero,
>>as they are the first items in their equivalence lists. However,
>>I'm unsure how best to fix this. My first thought was that this
>>test needs to be changed to (fl1->offset >= fl2->offset) but then
>>I realized that this introduces/preserves a curious assymmetry.
>>If "x" and "i" are equivalenced arrays, then "i" and "x" should
>>also be equivalenced.
>>
>>If not precisely sure what "offset" is supposed to represent, but
>>it if is a "byte" offset, i.e. a location in a COMMON block, then
>>we'd also need a length field in gfc_equiv_info to detect/confirm
>>an overlap.
>>
>>
>>Can anyone suggest the appropriate way to fix this?
>>
>>
Offset is taken directly from trans-common. It is indeed the offset of
the first byte of the equivelence element from the start of the
equivalence block. The inequality is chosen to sort out dependencies
for arrays or array sections going in the "normal" sense.
>
>I marveled at that line earlier myself. I think it's wrong. If offset is the
>number of storage units / bytes / whatever that the object is into the common
>block, then the inequality would not be correct for a dependency where the
>stride is negative (i.e. a(5:1:-1)), so I think the right course of action is
>to remove that check, and only do smart stuff if there are no equivalences
>involved.
>
>
The right thing to do is to change from > than to < if the stride is
negative and to flag a dependency when one is positive and the other is
negative. In the case of the example given, I would suspect that you
are right about >= being needed; together with a bit of index
arithmetic. I propose that we follow Tobi's suggestion by eliminating
the inequality condition but that a TODO be put there, saying that a bit
of index arithmetic would be worthwhile at some time. I do not have
time to return to this now so it should be flagged up for the future.
Cheers
Paul
More information about the Fortran
mailing list