Re: reducible loops

joel@decwrl.dec.com
Fri, 28 Feb 92 01:32:55 GMT

          From comp.compilers

Related articles
reducible loops preston@cs.rice.edu (1992-02-24)
Re: reducible loops rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) (1992-02-25)
Re: reducible loops preston@dawn.cs.rice.edu (1992-02-26)
Re: reducible loops lee@dumas.rutgers.edu (1992-02-26)
Re: reducible loops glew@pdx007.intel.com (1992-02-26)
Re: reducible loops preston@dawn.cs.rice.edu (1992-02-27)
Re: reducible loops joel@decwrl.dec.com (1992-02-28)
Re: reducible loops idacrd!desj@uunet.UU.NET (1992-03-09)
Re: reducible loops preston@dawn.cs.rice.edu (1992-03-10)
| List of all articles for this month |

Newsgroups: comp.compilers
From: joel@decwrl.dec.com
Keywords: optimize
Organization: DEC Western Research Laboratory
References: <9202220021.AA28153@ucbvax.Berkeley.EDU> 92-02-131
Date: Fri, 28 Feb 92 01:32:55 GMT

A much simpler related problem, which almost no compiler seems to get
right, is moving much of the switch statement overhead OUT of a loop, if
the switch expression is invariant inside the loop. Why, I don't know.
It's not much different from moving any other invariant out of the loop,
except that the invariant is a pc address rather than a data value.


#define blah(offset) ...


while (height != 0) {
/* No modifications to width inside loop. */
switch (width/4) {
case 7: blah(-32);
case 6: blah(-28);
...
case 0: blah(-4);
}
height--;
}


This is an example from real code in both MIT's and DEC's X servers.
Getting the code to run fast requires much programmer intervention, in the
form of assembly code, or in a truly excessive amount of C code that moves
the switch statement outside the (now 8 different) loop(s).


- Joel McCormack (decwrl!joel, joel@decwrl.dec.com)
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.