This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gfortran,patch] PR31399: handle large DO loops
- From: FX Coudert <fxcoudert at gmail dot com>
- To: "fortran at gcc dot gnu dot org List" <fortran at gcc dot gnu dot org>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 2 May 2007 23:02:05 +0200
- Subject: [gfortran,patch] PR31399: handle large DO loops
Hi all,
Attached patch fixes PR31399 by changing the code we generate for DO
loops. Except for simple loops (with step 1 or -1), we compute the
loop count and iterate by decreasing it until it reaches zero.
However, for the largest loop, the count can overflow the
corresponding unsigned type. (For example, the loop going from -huge
(0)-1 to huge(0) has 2*huge(0)+2 elements, while the largest unsigned
integer of this kind is 2*huge(0)+1.) The solution is to store the
loop count minus one, instead, and reorder the generated code.
Bootstrapped and regtested on i686-linux, it comes with a testcase
for both integer and real loops. OK for mainline? (It's a regression
wrt g77, but it affects very little user code, so I don't think it's
worth a backport.)
FX
:ADDPATCH fortran:
2007-05-02 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31399
* trans-stmt.c (gfc_trans_do): Handle large loop counts.
2007-05-02 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31399
* gfortran.dg/do_3.F90: New test.
Attachment:
large_do.diff
Description: Binary data