Skip to content

Commit

Permalink
0.8.21.26: provide %SQRT &co as functions on x86 for constant folding
Browse files Browse the repository at this point in the history
  • Loading branch information
nikodemus committed Apr 8, 2005
1 parent 472d737 commit 55e6ffb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/code/irrat.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@

) ; EVAL-WHEN

#!+x86 ;; for constant folding
(macrolet ((def (name ll)
`(defun ,name ,ll (,name ,@ll))))
(def %atan2 (x y))
(def %atan (x))
(def %tan-quick (x))
(def %cos-quick (x))
(def %sin-quick (x))
(def %sqrt (x))
(def %log (x))
(def %exp (x)))

;;;; stubs for the Unix math library
;;;;
;;;; Many of these are unnecessary on the X86 because they're built
Expand All @@ -54,9 +66,6 @@
(def-math-rtn "acos" 1)
#!-x86 (def-math-rtn "atan" 1)
#!-x86 (def-math-rtn "atan2" 2)
#!+x86 ;; for constant folding
(defun %atan2 (x y)
(%atan2 x y))
(def-math-rtn "sinh" 1)
(def-math-rtn "cosh" 1)
(def-math-rtn "tanh" 1)
Expand Down
27 changes: 27 additions & 0 deletions tests/float.impure.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,32 @@
(compile 'single-float-ppc)
(assert (= (single-float-ppc -30) -30f0))

;;; constant-folding irrational functions
(declaim (inline df))
(defun df (x)
;; do not remove the ECASE here: the bug this checks for indeed
;; depended on this configuration
(ecase x (1 least-positive-double-float)))
(macrolet ((test (fun)
(let ((name (intern (format nil "TEST-CONSTANT-~A" fun))))
`(progn
(defun ,name () (,fun (df 1)))
(,name)))))
(test sqrt)
(test log)
(test sin)
(test cos)
(test tan)
(test asin)
(test acos)
(test atan)
(test sinh)
(test cosh)
(test tanh)
(test asinh)
(test acosh)
(test atanh)
(test exp))

;;; success
(quit :unix-status 104)
2 changes: 1 addition & 1 deletion version.lisp-expr
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
"0.8.21.25"
"0.8.21.26"

0 comments on commit 55e6ffb

Please sign in to comment.