This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] PR54146 - rewrite rewrite_into_loop_closed_ssa
- From: Michael Matz <matz at suse dot de>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Guenther <richard dot guenther at gmail dot com>, Jan Hubicha <jh at suse dot cz>, marc dot glisse at inria dot fr
- Date: Thu, 16 Aug 2012 14:56:07 +0200 (CEST)
- Subject: Re: [patch] PR54146 - rewrite rewrite_into_loop_closed_ssa
- References: <CABu31nMJZ16jT9au_5_SXNm+pXY7OkdbuTYOiqjDfoNLZ5jBjQ@mail.gmail.com>
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.