------- Comment #7 from rguenth at gcc dot gnu dot org 2006-03-30 15:11 ------- You are probably right about improving SCEV - I hope Sebastian can make it work for this and similar cases. Wrt the loop header it is that we convert the loop to a do-while style loop, which at least iterates once, but to make this transformation valid, we need to copy the loop header. The "bug" is of course that we later try to prove again that this is a do-while style loop, which we could better have remembered somehow. I.e.
for (i = start; i < end; ++i) ; iterates end-start times, if start <= end. So we transform it to if (start < end) for (i = start; i < end; ++i) ; and later we "prove" that this new loop runs at least once by taking the loop exit condition and trying to simplify that based on dominating conditions from the loop header. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26939