[gfortran,patch] PR31399: handle large DO loops
FX Coudert
fxcoudert@gmail.com
Wed May 2 21:02:00 GMT 2007
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: large_do.diff
Type: application/octet-stream
Size: 9522 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070502/1ecd1169/attachment.obj>
More information about the Fortran
mailing list