This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/31399] Wrong code for do loop with large interation count



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]