This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: PR fortran/12840: Scalarisation of general array constructors


Thanks for the feedback.

Tobias.Schlueter@Physik.Uni-Muenchen.DE writes:
> I've not yet looked through the patch, so excuse me if you've already
> taken this into account, but it occured to me on reading your
> description that the realloc could be avoided in potentially many
> cases, by looking what shape the result must have: if in your example
> e.g. sub expects an array of length n, the constructor should contain
> n elements in the end.  The same holds if the constructor appears in
> an expression together with other arrays whose shape can be determined
> easily, e.g. something like

>    a(1:n) + (/ (gen (i), i = 1, order) /).

Yeah, the scalarisation code (and stevenb, it _is_ scalari_s_ation
where I come from ;) already has code to deal with this sort of thing.
It looks at each part of the scalarisation structure to see if it can
be used to determine the bounds.  In your example above, it will
consider using both a(1:n) and the array constructor.  And my patch
yields to non-constructors where possible:

Quoting Richard Sandiford <>:
>> Second, gfc_conv_loop_setup will now allow any constructor to be used
>> to determine the bounds of a scalarisation loop.  It will prefer to
>> use constructors over other sources if the constructor's size is a
>> compile-time constant.  However, because of the overheads involved in
>> dynamic reallocation, it will prefer to use other sources when the
>> size is not a compile-time constant.

"Other sources" would be a(1:n) in your example.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]