From dtc@scrooge.ee.swin.oz.au  Tue May 28 23:14:15 1996
Received: from scrooge.ee.swin.oz.au (scrooge.ee.swin.oz.au [136.186.4.20])
          by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id XAA09279
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 28 May 1996 23:14:13 -0700 (PDT)
Received: (from dtc@localhost) by scrooge.ee.swin.oz.au (8.6.9/8.6.9) id QAA11604 for FreeBSD-gnats-submit@freebsd.org; Wed, 29 May 1996 16:15:12 +1000
Message-Id: <199605290615.QAA11604@scrooge.ee.swin.oz.au>
Date: Wed, 29 May 1996 16:15:12 +1000 (EST)
From: Douglas Thomas Crosher  <dtc@scrooge.ee.swin.oz.au>
To: FreeBSD-gnats-submit@freebsd.org
Subject: Sun libm i387 'exp' leaves two valid values on the FP stack.

>Number:         1275
>Category:       bin
>Synopsis:       Sun libm i387 'exp' leaves two valid values on the stack
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bde
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 28 23:20:01 PDT 1996
>Closed-Date:    Sat Jun 1 11:02:45 PDT 1996
>Last-Modified:  Sat Jun  1 11:03:59 PDT 1996
>Originator:     Douglas Crosher
>Release:        FreeBSD 2.2-CURRENT i386
>Organization:
Swinburne University
>Environment:

	NA

>Description:

I've found what I think may be a bug with the 387 version of
'exp'. On return it leaves two valid values on the stack. I suspect
this does not conform to the C passing convention.

This may cause gcc some trouble if it tried to use all the FP regs as
it would receive a premature stack overflow.

Further, I'm trying to speed up C calls in CMUCL and have assumed that
C functions leave the FP stack empty unless a FP value is returned,
in which case it is on the ST and the rest the of regs are empty - the
behavior of exp, leaving two valid values on the stack, causes
trouble. 

>How-To-Repeat:

	Compile up the i387 version of the Sun libm. Then check the
return FP stack state for exp. Or look over the code and note that it
leaves two valid values on the stack.

>Fix:
	
*** e_exp.S.orig	Fri Aug 19 21:14:14 1994
--- e_exp.S	Tue May 28 23:30:45 1996
***************
*** 50,53 ****
--- 50,54 ----
  	fld1
  	faddp				/* 2^(fract(x * log2(e))) */
  	fscale				/* e^x */
+ 	fstpl	%st(1)
  	ret

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: jkh 
Responsible-Changed-When: Tue May 28 23:27:50 PDT 1996 
Responsible-Changed-Why:  
Bruce is the keeper of libm 
State-Changed-From-To: open->closed 
State-Changed-By: bde 
State-Changed-When: Sat Jun 1 11:02:45 PDT 1996 
State-Changed-Why:  
Patch applied on 1996/06/02: 
-current: 1.3 
-stable: 1.2.6.1 
>Unformatted:
