0.8.21.26: provide %SQRT &co as functions on x86 for constant folding
[sbcl.git] / tests / float.impure.lisp
index 36fdd6f..518a122 100644 (file)
   (declare (type (simple-array double-float (2)) p))
   (aref p 1))
 (defun order39 (points)
-  (sort points  #'(lambda (p1 p2)
-                    (let* ((y1 (point39-y p1))
-                           (y2 (point39-y p2)))
-                      (if (= y1 y2)
-                          (< (point39-x p1)
-                             (point39-x p2))
-                          (< y1 y2))))))
+  (sort points  (lambda (p1 p2)
+                 (let* ((y1 (point39-y p1))
+                        (y2 (point39-y p2)))
+                   (if (= y1 y2)
+                       (< (point39-x p1)
+                          (point39-x p2))
+                       (< y1 y2))))))
 (defun test39 ()
   (order39 (make-array 4
                       :initial-contents (list (point39 0.0d0 0.0d0)
                  #(2.0d0 2.0d0)
                  #(3.0d0 3.0d0))))
 
+(defun complex-double-float-ppc (x y)
+  (declare (type (complex double-float) x y))
+  (declare (optimize speed))
+  (+ x y))
+(compile 'complex-double-float-ppc)
+(assert (= (complex-double-float-ppc #c(0.0d0 1.0d0) #c(2.0d0 3.0d0))
+           #c(2.0d0 4.0d0)))
+
+(defun single-float-ppc (x)
+  (declare (type (signed-byte 32) x) (optimize speed))
+  (float x 1f0))
+(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)