Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!pyramid!prls!mips!earl@wright.mips.com From: earl@wright.mips.com (Earl Killian) Newsgroups: comp.arch Subject: Re: Procedure Call Protocol Message-ID: <8522@wright.mips.COM> Date: 19 Nov 88 20:19:20 GMT References: <3300037@m.cs.uiuc.edu> <5938@killer.DALLAS.TX.US> <7580@aw.sei.cmu.edu> <3926@omepd> Sender: earl@mips.COM Organization: MIPS Computer Systems, Sunnyvale CA Lines: 33 In-reply-to: mcg@omepd (Steven McGeady) In article <3926@omepd>, mcg@omepd (Steven McGeady) writes: >Mr. Firth wisely neglects to count in his 12 cycle cost the cost of saving >procedure-local registers to the stack. Typical C programs use between 4 and >12 procedure-local variables (variables local to the procedure which are not >referenced by enclosed scopes and thus can be allocated permanantly to >registers). This adds between 4 and 12 additional memory references at >call and return in either the calling site or the called site (depending on >whether you are using caller or callee save or some combination thereof). >If you (charitably) consider the average to be 6, and (charitably) assume >that Mr. Firth is running from zero-wait-state cache and that he gets no cache >misses, and (charitably) assume that he can fill the delay slots on three >of these stores, you are left with an additional 18 clocks, making Mr. Firth's >"12 cycle" (unoptimized) call/return into a 30 cycle call/return. Rather than "(charitably) considering the average to be 6", it would be better to measure it. I took 15 programs, sorted them by number of registers dynamically saved/restored, and picked the median. Here is its register save/restore statistics: Callee registers saved/restored at entry/exit: N entry entry% cum% regs% cum% instr% cum% 0 229298 11.8% 11.8% 0.0% 0.0% 0.0% 0.0% 1 1698070 87.0% 98.8% 95.3% 95.3% 3.3% 3.3% 2 6636 0.3% 99.1% 0.7% 96.1% 0.0% 3.3% 3 10637 0.5% 99.7% 1.8% 97.9% 0.1% 3.4% 4 2648 0.1% 99.8% 0.6% 98.5% 0.0% 3.4% 6 91 0.0% 99.8% 0.0% 98.5% 0.0% 3.4% 7 3854 0.2% 100.0% 1.5% 100.0% 0.1% 3.5% 10 1 0.0% 100.0% 0.0% 100.0% 0.0% 3.5% Total procedure entries: 1951235 Total register save/restore instructions: 1951235 (3.5%) Average registers saved per entry: 0.9 --