PING

On Fri, Dec 29, 2017 at 8:28 PM, Janne Blomqvist
<blomqvist.ja...@gmail.com> wrote:
> On Fri, Dec 29, 2017 at 7:17 PM, Thomas Koenig <tkoe...@netcologne.de> wrote:
>> Hi Janne,
>>
>>> Using pointer sized variables (e.g. size_t / ptrdiff_t) when the
>>> variables are used as array indices allows accessing larger arrays,
>>> and can be a slight performance improvement due to no need for sign or
>>> zero extending, or masking.
>>
>>
>> Unless I have missed something, all the examples are for cases where
>> the array is of maximum size GFC_MAX_DIMENSIONS.
>
> Many, but not all.
>
>> This is why they
>> were left as int in the first place (because it is unlikely we will have
>> arrays of more than 2^31-1 dimensions soon :-).
>>
>> Do you really think this change is necessary? If not, I'd rather avoid
>> such a change.
>
> I'm not planning on supporting > 2**31-1 dimensions, no. :)
>
> But even if we know that the maximum value is always going to be
> smaller, by using pointer-sized variables the compiler can generate
> slightly more efficient code.
>
> See e.g. https://godbolt.org/g/oAvw5L ; in the functions with a loop,
> the ones which use pointer-sized indices have shorter preambles as
> well as loop bodies. And for the simple functions that just index an
> array, by using pointer-sized indices there is no need to zero the
> upper half of the registers.
>
> I mean, it's not a huge improvement, but it might be a tiny one in some cases.
>
> Also, by moving the induction variable from the beginning of the
> function into the loop header, it makes it easier for both readers and
> the compiler to see the scope of the variable.
>
> --
> Janne Blomqvist



-- 
Janne Blomqvist

Reply via email to