Hi, On Wed, 15 Aug 2012, Steven Bosscher wrote:
Please convince me that this : +/* Return the outermost superloop LOOP of USE_LOOP that is a superloop of + both DEF_LOOP and USE_LOOP. */ +static inline struct loop * +find_sibling_superloop (struct loop *use_loop, struct loop *def_loop) +{ + unsigned ud = loop_depth (use_loop); + unsigned dd = loop_depth (def_loop); + gcc_assert (ud > 0 && dd > 0); + if (ud > dd) + use_loop = superloop_at_depth (use_loop, dd); + if (ud < dd) + def_loop = superloop_at_depth (def_loop, ud); + while (loop_outer (use_loop) != loop_outer (def_loop)) + { + use_loop = loop_outer (use_loop); + def_loop = loop_outer (def_loop); + gcc_assert (use_loop && def_loop); + } + return use_loop; doesn't have the usual problem of advancing two iterators at the same time and expecting they'll eventually meet (which they generally don't have to). Also the block comment indicates that could should just as well return the outermost loop of the function, because it's the "outermost superloop LOOP of USE_LOOP that is a superloop of both DEF_LOOP and USE_LOOP." The implementation seems to want to return the _innermost_ superloop that still covers both DEF_LOOP and USE_LOOP, and in that case my concern about them never meeting stands. Ciao, Michael.