Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!spdcc!iecc!compilers-sender From: meissner@osf.org Newsgroups: comp.compilers Subject: Re: Inlining and global references Keywords: architecture, optimize Message-ID: <9105031839.AA10328@curley.osf.org> Date: 3 May 91 18:39:12 GMT References: <1991May2.212633.6893@beaver.cs.washington.edu> <1991May1.035622.25021@daffy.cs.wisc.edu> Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: meissner@osf.org Organization: Compilers Central Lines: 34 Approved: compilers@iecc.cambridge.ma.us | carter@cs.wisc.edu (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: meissner@osf.org 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] -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.