Path: utzoo!news-server.csri.toronto.edu!rutgers!apple!amdcad!dvorak.amd.com!proton!tim From: tim@proton.amd.com (Tim Olson) Newsgroups: comp.arch Subject: Re: register save Message-ID: <1991Mar13.173856.23261@dvorak.amd.com> Date: 13 Mar 91 17:38:56 GMT References: <1991Mar11.192116.1974@dgbt.doc.ca> <912@spim.mips.COM> <3255@crdos1.crd.ge.COM> Sender: usenet@dvorak.amd.com (Usenet News) Reply-To: tim@amd.com (Tim Olson) Organization: Advanced Micro Devices, Austin, TX Lines: 61 In article <3255@crdos1.crd.ge.COM> davidsen@crdos1.crd.ge.com (bill davidsen) writes: | Well I'm not about to argue but I may pose a question, in systems | which use register windows, does someone have a good handle on the cost | of doing all the register to register I see just before a call? I see | some papers which show big gains by not moving data register to memory | to register putting arguments on a stack, but they seem to discount the | cost of the moves, and the reduced performance of the optimizer having | to treat a lot of registers as temps or plain unusable. I would have to | read some papers to clearly unstand how to measure the optimizer impact, | so if someone has done it speak up. The register-to-register movement that you mention is not due to a windowed-register implementation; simply passing parameters in registers will cause this, because a function may be called by more than one parent, and they all must agree on what registers the parameters must be passed in. However, the register-to-register movement is not required all the time; register allocators can bind local variables to the correct outgoing parameter register through copy propagation. For example, the function: ---------------------------------------- void g(int, int, int); void f(int j) { int i1, i2; i1 = j+5; i2 = j-7; g(i2, j, i1); } ---------------------------------------- compiles to the following, using the MetaWare C compiler for the 29K: ---------------------------------------- _f: sub gr1,gr1,24 asgeu V_SPILL,gr1,gr126 add lr1,gr1,36 ;5 | int i1, i2; <- local variables i1, i2 ;6 | ;7 | i1 = j+5; add lr4,lr8,5 <- i1 is assigned local register 4 ;8 | i2 = j-7; (3rd parameter reg) sub lr2,lr8,7 <- i2 is assigned local register 2 ;9 | g(i2, j, i1); (1st parameter reg) call lr0,_g <- so this call needs no copying, add lr3,lr8,0 <- except incoming parameter j ;10 |} add gr1,gr1,24 nop jmpi lr0 asleu V_FILL,lr1,gr127 ---------------------------------------- -- -- Tim Olson Advanced Micro Devices (tim@amd.com)