Re: Inlining and global references
Fri, 3 May 91 14:39:12 -0400

          From comp.compilers

Related articles
Re: Inlining and global references (1991-05-03)
Re: Inlining and global references (1991-05-05)
| List of all articles for this month |

Newsgroups: comp.compilers
Keywords: architecture, optimize
Organization: Compilers Central
References: <> <>
Date: Fri, 3 May 91 14:39:12 -0400

| (Gregory Carter) writes:
| >[Optimize:
| > (1) local vars -> global vars
| > (2) replace subroutine calls with the subroutine code
| > (3) minimize stack frame usage]
| On many machines (RISC machines in particular), accesing global memory is
| no faster than accessing local variables.

Actually on RISC machines, accessing global memory may be slower than
accessing local variables. This is because RISC machines typically cannot
reference all of memory with one instruction. To reference x, they do two
instructions -- set a register with the high part of the address, and do
the memory reference with the loaded register, and the lower part of the
address as an offset. On the MIPS this would be:

lui $at,x ; load assembler temp with high 16 bits of x
lw $2,x ; load memory

Now, the MIPS assembler expands the 'lw' macro into the two instructions
above. Also, the MIPS software conventions has a dedicated register to
hold the address of a 64K pool, which small sized globals are placed, and
only one instruction is used if the assembler is told that the item is
located there.

Michael Meissner email: phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
[Even on CISCs like a Vax or a 386 a stack reference is shorter than an
absolute reference, since you can typically use a single-byte offset rather
than a 4-byte address. -John]

Post a followup to this message

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