This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31399] Wrong code for do loop with large interation count
- From: "hjl at lucon dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 May 2007 20:36:28 -0000
- Subject: [Bug fortran/31399] Wrong code for do loop with large interation count
- References: <bug-31399-10259@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from hjl at lucon dot org 2007-05-21 21:36 -------
According to the comment, before the change, we performed
[evaluate loop bounds and step]
count = (to + step - from) / step;
dovar = from;
for (;;)
{
body;
cycle_label:
dovar += step
count--;
if (count <=0) goto exit_label;
}
exit_label:
After the change, we did
[evaluate loop bounds and step]
empty = (step > 0 ? to < from : to > from);
countm1 = (to - from) / step;
dovar = from;
if (empty) goto exit_label;
for (;;)
{
body;
cycle_label:
dovar += step
countm1--;
if (countm1 ==0) goto exit_label;
}
exit_label:
Didn't we do one loop less than before?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31399