public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/48363] New: Recursion not converted into a loop
@ 2011-03-30 12:40 burnus at gcc dot gnu.org
  2011-03-30 15:06 ` [Bug fortran/48363] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-03-30 12:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48363

           Summary: Recursion not converted into a loop
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


For the following Fortran program, the recursion could be replaced by a loop.
That's what happening for the related C program, but for the Fortran program
the recursion remains. (Tried with -O3.)

(I guess the I/O statement (_gfortran_st_write* and _gfortran_transfer_*_write)
confuse the ME, but I do not see why that should prevent the loop
transformation. Hints how to modify the FE to help the ME are welcome, too.)

! Fortran version
call x (1)
contains
  recursive subroutine x (i)
    use iso_fortran_env
    integer, value :: i
    if (mod (i, 1000000) == 0) write (error_unit,'(a,i0)')'i=', i
    call x (i+1)
  end subroutine x
end


/* C version */
#include <stdio.h>
static void
x (int i) {
  if (!(i % 1000000))
    fprintf(stderr, "i=%d\n", i);
  x(i + 1);
}
int main () {
  x (1);
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-10 23:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-30 12:40 [Bug fortran/48363] New: Recursion not converted into a loop burnus at gcc dot gnu.org
2011-03-30 15:06 ` [Bug fortran/48363] " rguenth at gcc dot gnu.org
2011-03-30 15:51 ` burnus at gcc dot gnu.org
2011-03-30 15:58 ` rguenth at gcc dot gnu.org
2021-08-10 23:18 ` [Bug tree-optimization/48363] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).