Article View: comp.sys.amiga.tech
Article #9171Re: Lattice 4.1 register yuck!
From: Matt Dillon
Date: Tue, 21 Jun 1988 21:23
Date: Tue, 21 Jun 1988 21:23
70 lines
2228 bytes
2228 bytes
: One expects the register variable i to be dead after the last brace
: and thus available for re-use, right? Wrongo! Lattice doesn't
: think so.
Damn right it should. I do the same sort of thing... use localized
register variables.
One thing I have yet to see addressed properly by either Aztec or
Lattice is the following:
{
register short i, j, k;
for (i = 0; i < 10; ++i)
<blah>
for (j = 0; j < 10; ++j)
<blah>
for (k = 0; k < 10; ++k)
<blah>
}
I is not used while J is being used, neither I or J are being
used while K is being used, etc....
ONLY ONE REGISTER SHOULD BE USED FOR ALL THREE REGISTER VARIABLES!!
Often, I have all sorts of temporary variables of differing types
(usually differing pointer types), and even though I use them
sequentially (where the same register could have been used), the
compiler always assigns different registers to them. Allowing
multiple register variables to 'share' registers under the above
circumstances greatly increases register utilization.
:Or how bout this:
:
: { short i[100];
: i[0] = 12;
: }
:
: You would expect the space for i on the stack to be freed after the last
: brace for re-use. Nope.
Actually, no. Usually, stack space is overlayed:
{
{
char x[256];
<blah>
}
{
char y[256];
<blah>
}
}
I.e. all stack is allocated at entry. In this case, 256 bytes should
be allocated because x and y do not mix. Think about the efficiency
this gives you. You have a tight loop:
for (i = 0; i < 1000; ++i) {
short x = i << 2;
<blah>
}
You do NOT want stack space to be allocated and deallocated for
every loop!!!! That's right, the variable x DIES on every loop
by semantics.
-Matt
Technical Details
Message-ID:
<8806212123.AA01328@cory.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!CORY.BERKELEY.EDU!dillonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: Lattice 4.1 register yuck! Message-ID: <8806212123.AA01328@cory.Berkeley.EDU> Date: 21 Jun 88 21:23:40 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 70