public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/35344]  New: Loop unswitching to produce perfect loop nest
@ 2008-02-24  4:33 xinliangli at gmail dot com
  2008-02-24 21:55 ` [Bug tree-optimization/35344] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: xinliangli at gmail dot com @ 2008-02-24  4:33 UTC (permalink / raw)
  To: gcc-bugs

GCC loop unswitching is very good -- handles most of the cases I tried. The
only only thing I notice is that the nested for loops in C in the example below
is not converted into a perfect loop nest:

int** p;

int** q;

void foo(int m, int n)
{
   int i, j;

   for (i = 0;  i < m; i++)
   {
      for (j = 0; j < n ; j++)
     {
        p[i][j] += q[i][j];
        q[i][j] ++;
     }
   }

}

It is generated into (roughly) the following code by gcc (-O3
-fno-tree-vectorize)

 if (m > 0)
 {
      do
      {
          if (n > 0 )
          {
              do
              {
                 p[i][j] += q[i][j];
                 q[i][j] += 1;
                 j += 1;
              } while ( j < n);
          }
          i+=1;
     } while (i < m);
 }

Ideally-- it should be:

 if (m > 0)
 {
    if (n >0)
    {
        do
        {
            do
            {
              ....
              j++;
            } while(...);
            i++;
        }while (...);
     }
    // empty loop deleted
}


-- 
           Summary: Loop unswitching to produce perfect loop nest
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: xinliangli at gmail dot com


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug tree-optimization/35344] Loop unswitching to produce perfect loop nest
  2008-02-24  4:33 [Bug middle-end/35344] New: Loop unswitching to produce perfect loop nest xinliangli at gmail dot com
@ 2008-02-24 21:55 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-24 21:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-02-24 21:54 -------
I think this is a dup of PR23855.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rakdver at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |enhancement
          Component|middle-end                  |tree-optimization
           Keywords|                            |missed-optimization
            Version|unknown                     |4.3.0


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-24 21:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-24  4:33 [Bug middle-end/35344] New: Loop unswitching to produce perfect loop nest xinliangli at gmail dot com
2008-02-24 21:55 ` [Bug tree-optimization/35344] " rguenth at gcc dot gnu dot org

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