From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 13847 invoked from network); 13 Jul 1998 01:08:42 -0000 Received: from stefan.sime.com (193.228.80.247) by mail2.redhat.com with SMTP; 13 Jul 1998 01:08:42 -0000 Received: (from stefan@localhost) by stefan.sime.com (8.8.7/8.8.7) id DAA03486; Mon, 13 Jul 1998 03:06:31 +0200 Date: Mon, 13 Jul 1998 03:06:31 +0200 Message-Id: <199807130106.DAA03486@stefan.sime.com> From: Quant-X Alpha Linux Support To: axp-list@redhat.com In-reply-to: (message from Dave Gilbert on Sun, 12 Jul 1998 19:56:33 +0100 (BST)) Subject: Re: Function call oddity MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: Quant-X Alpha Linux Support Reply-To: Quant-X Alpha Linux Support Organization: Quant-X Service & Consulting Ges.m.b.H. X-Mailer: GNU Emacs 20.2.1 C-x m (X11 ; I; Linux 2.1.108 i586) References: Hi David ! > However if the routine has one parameter and a result > then it runs faster than a similar routine without a parameter!! > > This is really unexpected to me; by the look of the code it must be > to do with allocation of space on the stack at a guess - wierd!! No, not stack at all. Up to six parameters will be passed by registers. I saw the same effect two months ago. The funny thing is: void func(void) int func(int) caller-loop 6 7 instructions func 6 7 instructions The difference is in the caller loop: Without args, we have the following scheme: LABEL: jsr $26, func ... ... ... bne $1, LABEL This means two branches in two instruction cycles (first the conditional and then the subroutine branch.) This is IMHO not really optimal. The version with a dummy arg starts with "bis $31, $31, $16" in LABEL everything else is the same. This is the original loop by egcs for calling void a(void); in a loop .align 5 $L4: jsr $26,a ldgp $29,0($26) bis $9,$9,$1 cmple $1,$10,$1 addl $9,1,$9 bne $1,$L4 This is !!!slower!!! than .align 5 $L4: nop jsr $26,a ldgp $29,0($26) bis $9,$9,$1 cmple $1,$10,$1 addl $9,1,$9 bne $1,$L4 I've only added the famous "nop". I hope Richard Henderson reads this, too ;-}} Stefan Traby -- Quant-X Service & Ph: (+43) 4212 6004-0 Consulting Ges.m.b.H. Fax: (+43) 4212 600420 http://www.quant-x.com Email: support@quant-x.com