This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: [RFH] More inline-expansion of SUM intrinsic


On 27.04.2010 16:44, Richard Guenther wrote:
Here's an updated patch, I solved the used-as-function arg problem
and cleaned it up.  Remaining issues are storing the loop index
in a gfc_expr and a new problem, translating this loop index to
its proper value (there must be a helper for this somewhere),
Hello, I have looked at it.
I think the function you are looking for is gfc_conv_scalarized_array_ref or gfc_conv_array_index_offset, but they are rather scalarizer-oriented (you need a proper gfc_ss_info) so I thought we could (mis?)use the scalarizer to manage bounds and loops.


I attach my patch (much deviated from your). It adds the sum argument to the scalarizing chain, hiding the dimension on which the sum will happen (so that it doesn't look too odd to the scalarizer), and restoring it later when we need it (whilst translating the argument). It is not very nice looking, but has the benefit of making little assumptions on what the argument will look like. It may not play well with dependencies (and temporaries) though... And for now, the code produced looks quite right but is not :-(. It seems offsets are wrong.

otherwise we get two FAILs,

FAIL: gfortran.fortran-torture/execute/intrinsic_sum.f90 execution, *
FAIL: gfortran.dg/intrinsic_intkinds_1.f90 * execution test

reduced testcase for the first one:

program testforall
    implicit none
    integer, dimension (3, 3) :: a
    character(len=9) line

a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/));

    write (line, 9000) sum (a, 1)
    if (line .ne. '  6 15 24') call abort

9000 format(3I3)
end program

where we index the sum () result with 0, 1, 2 instead of 1, 2, 3.
Didn't look but it might be the change for choosing loopspec[n] in gfc_conv_loop_setup

Bye
Mikael

Attachment: inlining.diff
Description: Text document


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