[PATCH] PR fortran/31593: Speed up loops with DO variables as procedure arguments

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Mon Aug 24 20:36:00 GMT 2009


Which patch you ask?  This patch.

Sorry,
- Tobi

Tobias Schlüter wrote:
> 
> Hi,
> 
> the attached patch speeds up loops where the DO variable is used as an 
> actual argument in a procedure call such as
>  DO I=1,1000
>     CALL sub(i)
>  END DO
> The speedup is achieved by copying the loop var before passing it as an 
> argument.  This is possible because the callee is not allowed to change 
> it, i.e. the code will be compiled as if it read
>  DO I=1,1000
>     I_temp = i
>     CALL sub(i)
>  END DO
> 
> This speeds up the slow version of Thomas's testcase in comment #23 of 
> the PR: it now runs as fast as the fast version.
> 
> This optimization is not performed when I is a TARGET, see the new 
> testcase to see why (it works before the patch, but this particular item 
> appears to have no testcase).
> 
> Built & tested, polyhedron shows no measurable change.  I would 
> appreciate if someone who's more versed in the middle-end stuff takes a 
> look if the trans-expr.c hunk makes sense.  I just tried to make it 
> work, and it seems to, but that doesn't make it right.
> 
> Cheers,
> - Tobi

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr31593.diff.txt
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090824/3fe523f5/attachment.txt>


More information about the Fortran mailing list