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]

[FORTRAN PATCH]: Further compute_overall_iter_number improvements


The following patch is another improvement to the way gfortran translates
nested FORALL statements into gimple.  Now that the data-structure used to
represent forall loop nests has been simplified, it's now possible for
trans-stmt.c to use gfc_trans_nested_forall_loop to expand just the "N"
outermost loops instead of the whole forall nest.  This allows another
generalization of the code in compute_overall_iter_number which determines
the number of times a loop body will be executed.

As explained in one of my previous patches to this function
http://gcc.gnu.org/ml/fortran/2007-01/msg00388.html
It's possible to determine the iteration number at compile-time when the
loops are unconditional with constant bounds.  We can use a similar
strategy to simplify the calculation when the innermost loops are
unconditional with constant bounds, and eliminate/peel some of the inner
loops from the loop stack.

So in an example code such as:

  integer :: it(3,2)
  forall (i = 1:2, i < 3)
    forall (j = 1:2)
      it(i+1,j) = it(i,j)
    end forall
  end forall
end

we no longer need to loop over both i and j to determine how many times
the assignment is executed.  We only need to loop over i, evaluating the
conditional, and then multiply the result by two.

This is implemented in the change below.

The following patch has been tested on x86_64-unknown-linux-gnu, with a
full "make bootstrap", including gfortran, and regression tested with a
top-level "make -k check" with no new failures.

Ok for mainline?


2007-01-30  Roger Sayle  <roger@eyesopen.com>

        * trans-stmt.c (compute_overall_iter_number): Document function
        arguments.  Generalize "unconditional forall nest with constant
        bounds" optimization to eliminate unconditional inner loops with
        constant bounds.

Roger
--

Attachment: patchf1.txt
Description: Text document


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