Path: 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 : 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)for (j = 0; j < 10; ++j) for (k = 0; k < 10; ++k) } 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]; } { char y[256]; } } 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; } 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