public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/23855] loop header should also be pulled out of the inner loop too
Date: Mon, 10 Apr 2006 08:11:00 -0000	[thread overview]
Message-ID: <20060410081059.7951.qmail@sourceware.org> (raw)
In-Reply-To: <bug-23855-10053@http.gcc.gnu.org/bugzilla/>



------- Comment #17 from rguenther at suse dot de  2006-04-10 08:10 -------
Subject: Re:  loop header should also be pulled
 out of the inner loop too

On Mon, 9 Apr 2006, rakdver at gcc dot gnu dot org wrote:

> (In reply to comment #14)
> > (In reply to comment #11)
> > > I updated the patch for current mainline, but it still has issues for some
> > > common uses of loops:
> > > 
> > > void foo(int *ie, int *je, double *x)
> > > {
> > >   int i, j;
> > >   for (j=0; j<*je; ++j)
> > >     for (i=0; i<*ie; ++i)
> > >       x[i+j] = 0.0;
> > > }
> > > 
> > > After loop header copying we have
> > > 
> > >   if (*je > 0)
> > >     for (j=0; j<*je; ++j)
> > >       if (*ie > 0)
> > >         for (i=0; i<*ie; ++i)
> > >           x[i+j ] = 0.0;
> > > 
> > > note how in this form we see the condition *ie > 0 not invariant wrt the
> > > outer loop (because it does a memory load), but if we would run load-PRE
> > > between loop header copying and guard hoisting we would get
> > 
> > actually, thinking about it again, it should suffice to teach
> > invariant_without_guard_p about invariant memory loads, and this should just
> > work.
> 
> It basically does, the only other problem is that we are not able to determine
> that the outer loop is not infinite.

It that because we don't recognize the condition of the loop header?  
Otherwise we know that *je > 0 and the loop runs from 0 to *je (in fact,
I have loop determine the number of iterations of the loop to be *je).  Of
course this is with load-PRE moving the load before the loop-header and 
thus SCEV being presented with

   D.xxx = *je;
   if (D.xxx > 0)
     for (j=0; j<D.xxx; ++j)
      ...

which it just handles fine.  It looks like a chicken-and-egg problem ;)

Richard.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23855


  parent reply	other threads:[~2006-04-10  8:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-23855-10053@http.gcc.gnu.org/bugzilla/>
2006-01-15 20:08 ` pinskia at gcc dot gnu dot org
2006-01-15 20:12 ` pinskia at gcc dot gnu dot org
2006-01-15 20:15 ` rakdver at gcc dot gnu dot org
2006-01-17 22:28 ` rakdver at gcc dot gnu dot org
2006-01-20 23:57 ` rakdver at gcc dot gnu dot org
2006-02-28 18:23 ` patchapp at dberlin dot org
2006-04-07 11:35 ` rguenth at gcc dot gnu dot org
2006-04-07 12:01 ` rguenth at gcc dot gnu dot org
2006-04-07 12:57 ` rakdver at atrey dot karlin dot mff dot cuni dot cz
2006-04-07 13:20 ` rakdver at gcc dot gnu dot org
2006-04-09 23:51 ` rakdver at gcc dot gnu dot org
2006-04-10  0:04 ` rakdver at gcc dot gnu dot org
2006-04-10  8:11 ` rguenther at suse dot de [this message]
2006-04-10 10:24 ` rakdver at atrey dot karlin dot mff dot cuni dot cz
2006-04-10 11:56 ` rguenth at gcc dot gnu dot org
2006-10-24 13:56 ` rguenth at gcc dot gnu dot org
2006-10-24 13:59 ` rakdver at gcc dot gnu dot org
2006-10-24 14:23 ` dberlin at gcc dot gnu dot org
     [not found] <bug-23855-4@http.gcc.gnu.org/bugzilla/>
2011-10-19 19:11 ` pinskia at gcc dot gnu.org
2011-10-20  7:44 ` rguenther at suse dot de
2012-12-07 10:13 ` rguenth at gcc dot gnu.org
2014-02-05 14:13 ` rguenth at gcc dot gnu.org
2014-02-05 14:14 ` rguenth at gcc dot gnu.org
2014-02-05 14:27 ` rguenth at gcc dot gnu.org
2021-07-26  3:36 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060410081059.7951.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).