This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Fortran-dev][Patch, Fortran] C_F_Pointer cleanup
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: Mikael Morin <mikael dot morin at sfr dot fr>, gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Fri, 20 Jul 2012 12:35:49 +0200
- Subject: Re: [Fortran-dev][Patch, Fortran] C_F_Pointer cleanup
- References: <500261E6.4070000@net-b.de> <50092A41.2020406@sfr.fr> <5009301F.7040101@net-b.de>
On Fri, Jul 20, 2012 at 12:17 PM, Tobias Burnus <burnus@net-b.de> wrote:
> On 07/20/2012 11:52 AM, Mikael Morin wrote
>>
>> OK.
>
>
> Thanks for the review.
>
>
>> I guess the division will be dropped too (the middle-end does the
>> reverse multiplication implicitly in the pointer arithmetic).
>> I wonder which one is faster (the casts in the second version are
>> certainly not nice for the middle-end):
>>
>> ptr + (offset_in_bytes / elt_size_in_bytes)
>> VS
>> (sometype *) (((char *)ptr) + offset_in_bytes)
>
>
> As we have to support strides which aren't multiples of the element size, we
> have to use the second form. We currently do so for BT_CLASS but not for
> BT_TYPE. Actually, half of the remaining failures on the branch seem to be
> due to the wrong usage of stride- vs. byte-based offsets. For instance in
> SELECT TYPE .. TYPE IS, where one has a BT_TYPE and which fails.
>
> I think the conversion to byte offsets will be the next step. Afterwards, we
> should get rid of the offset.
The middle-end POINTER_PLUS_EXPR requires byte offsets for all
pointer types, so you can avoid the conversion to char * if ptr is already
a pointer type.
Richard.
> Tobias