0.8.21.26: provide %SQRT &co as functions on x86 for constant folding
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 8 Apr 2005 14:22:54 +0000 (14:22 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 8 Apr 2005 14:22:54 +0000 (14:22 +0000)
src/code/irrat.lisp
tests/float.impure.lisp
version.lisp-expr

index ef7f6a3..25a5f8b 100644 (file)
 
 ) ; EVAL-WHEN
 \f
+#!+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
@@ -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)
index 7225011..518a122 100644 (file)
 (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)
index a8cae07..dd903df 100644 (file)
@@ -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"