Dear Dominique,

> The patch works as advertised! I have two remarks:

Of course it does :-)

>
> (1) AFAIU there is no need for a temporary for

Indeed not. I cannot see how that can be avoided without a much more
elaborate patch. Frankly, I do not see that it would be warranted.
Much better some extra temporaries in corner cases, than wrong code.
>
> PROGRAM Main
>     INTEGER :: i, index(5) = (/ (i, i = 1,5) /)
>     REAL :: tmp(5), array(5) = (/ (i+0.0, i = 1,5) /)
>     tmp = Fred(index,array)
>     array = tmp
>     PRINT *, array
> CONTAINS
>     ELEMENTAL FUNCTION Fred (n, x)
>         REAL :: Fred
>         INTEGER, INTENT(IN) :: n
>         REAL, INTENT(IN) :: x
>         ! In general, this would be in an external procedure
>         Fred = x+SUM(array(:n-1))+SUM(array(n+1:))
>      END FUNCTION Fred
> END PROGRAM Main
>
> However I get
>
> [Book15] f90/bug% gfc elemental_weird_db_2.f90 -Warray-temporaries
> elemental_weird_db_2.f90:4:10:
>
>      tmp = Fred(index,array)
>           1
> Warning: Creating array temporary at (1) [-Warray-temporaries]
>
> (2) You wrote: << However, this works and has no perceivable effect on 
> Polyhedron timings. >>. This is hardly a surprise since the Polyhedron tests 
> don't use any elemental procedure.

:-) You might have gathered that I didn't check! Within errors, it
didn't affect compile times either.

Thanks for the feedback

Paul

>
> Thanks,
>
> Dominique
>
>> Le 10 févr. 2015 à 23:35, Paul Richard Thomas 
>> <paul.richard.tho...@gmail.com> a écrit :
>>
>> Dear Mikael, dear all,
>>
>> Thank you for the previous review. I believe that the attached
>> responds to all of your comments and correctly compiles the three
>> testcases that you provided. Two of these have been included in the
>> original testcase and the third appears separately.
>>
>> Bootstrapped and reg
>> tested on FC21/x86_64 - OK for trunk?
>>
>> Cheers
>>
>> Paul
>>
>> 2015-02-10  Paul Thomas  <pa...@gcc.gnu.org>
>>
>>    PR fortran/64952
>>    * gfortran.h : Add 'array_outer_dependency' to symbol_attr.
>>    * trans.h : Add 'array_outer_dependency' to gfc_ss_info.
>>    * module.c : Add AB_ARRAY_OUTER_DEPENDENCY to ab_attribute.
>>    Add same to attr_bits.
>>    (mio_symbol_attribute): Handle 'array_outer_dependency' attr
>>    in module read and write.
>>    * resolve.c (resolve_function): If an elemental function is
>>    referenced that is marked as having an external array reference
>>    and the current namespace is that of an elemental function,
>>    mark the containing function likewise.
>>    (resolve_variable): Mark elemental function symbol
>>    as 'array_outer_dependency' if it has an array reference from
>>    outside its own namespace.
>>    * trans-array.c (gfc_conv_resolve_dependencies): If any ss is
>>    marked as 'array_outer_dependency' generate a temporary.
>>    (gfc_walk_function_expr): If the function is marked as
>>    'array_outer_dependency', likewise mark the head gfc_ss.
>>
>> 2015-02-10  Paul Thomas  <pa...@gcc.gnu.org>
>>
>>    PR fortran/64952
>>    * gfortran.dg/elemental_dependency_4.f90: New test
>>    * gfortran.dg/elemental_dependency_5.f90: New test
>



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

Reply via email to