Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Mark Probst <schani@unix.cslab.tuwien.ac.at>
To: axp-list@redhat.com
Subject: Re: Alpha's floating point performance
Date: Thu, 19 Nov 1998 10:33:02 +0000	[thread overview]
Message-ID: <19981119103302.C4987@obiwan.unix.cslab.tuwien.ac.at> (raw)
In-Reply-To: <Pine.LNX.3.95.981118163616.25933I-100000@norad.dodds.net>; from Bibek Sahu on Wed, Nov 18, 1998 at 04:41:40PM -0600

On Wed, Nov 18, 1998 at 04:41:40PM -0600, Bibek Sahu wrote:
> 	If you don't activate optimizations, it most certainly does push
> the arguments onto the stack.  And inside the function it pushes all local
> variables onto the stack.  But then, that's _without_ optimizations. ;-) 

yes and no. i just tried it out (gcc -S test.c) and was surprised that
the arguments are pushed on the stack by the called function, not by
the caller. this means that argument passing is done the same way, namely
through registers $16-$21, which, by the way, is a must because otherwise
you could not link optimized and unoptimized code.

this is the source i compiled:

---
long
c_func (long l)
{
  return l + 1;
}
---

and this is the assembler output without optimizations, annotated by
my humble self:

---
        .globl c_func
        .ent c_func
c_func:
c_func..ng:
        lda $30,-32($30)         ; allocate stack frame
        .frame $15,32,$26,0
        stq $26,0($30)           ; push return adress
        stq $15,8($30)           ; push frame pointer
        .mask 0x4008000,-32
        bis $30,$30,$15          ; set frame pointer = stack pointer
        .prologue 0
        stq $16,16($15)          ; push argument on stack
        ldq $2,16($15)           ; load argument from stack
        addq $2,1,$1             ; add one to argument
        bis $1,$1,$0             ; store result in result register
        br $31,$33               ; jump to $33
$33:
        bis $15,$15,$30          ; set stack pointer = frame pointer
        ldq $26,0($30)           ; load return address from stack
        ldq $15,8($30)           ; load frame pointer from stack
        addq $30,32,$30          ; deallocate stack frame
        ret $31,($26),1          ; return from subroutine
        .end c_func
---

this is the optimized version (-O2):

---
        .globl c_func
        .ent c_func
c_func:
c_func..ng:
        .frame $30,0,$26,0
        .prologue 0
        addq $16,1,$0            ; set result register = argument + 1
        ret $31,($26),1          ; return from subroutine
        .end c_func
--- 

bye
schani

-- 
Mark Probst
Student, Programmer
http://www.unix.cslab.tuwien.ac.at/~schani/


  reply	other threads:[~1998-11-19 17:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.3.96.981117143804.30989B-100000@bach.ce.gatech.edu>
1998-11-18 21:15 ` Alpha's floating point performance Chris Albertson
1998-11-18 22:26   ` Mark Probst
1998-11-18 22:41     ` Bibek Sahu
1998-11-19 10:33       ` Mark Probst [this message]
1998-11-16 22:51 y0000218
1998-11-17  9:09 ` Harvey J. Stein
1998-11-17 16:11 ` Scott Lewis
1998-11-17 19:36   ` Chris Albertson
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox