+ #(#(0.0d0 0.0d0)
+ #(1.0d0 1.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))
+
+;;; Broken move-arg-double-float for non-rsp frame pointers on x86-64
+(defun test (y)
+ (declare (optimize speed))
+ (multiple-value-bind (x)
+ (labels ((aux (x)
+ (declare (double-float x))
+ (etypecase y
+ (double-float
+ nil)
+ (fixnum
+ (aux x))
+ (complex
+ (format t "y=~s~%" y)))
+ (values x)))
+ (aux 2.0d0))
+ x))
+
+(assert (= (test 1.0d0) 2.0d0))
+
+(deftype myarraytype (&optional (length '*))
+ `(simple-array double-float (,length)))
+(defun new-pu-label-from-pu-labels (array)
+ (setf (aref (the myarraytype array) 0)
+ sb-ext:double-float-positive-infinity))
+
+;;; bug 407
+;;;
+;;; FIXME: it may be that TYPE-ERROR is wrong, and we should
+;;; instead signal an overflow or coerce into an infinity.
+(defun bug-407a ()
+ (loop for n from (expt 2 1024) upto (+ 10 (expt 2 1024))
+ do (handler-case
+ (coerce n 'single-float)
+ (simple-type-error ()
+ (return-from bug-407a :type-error)))))
+(assert (eq :type-error (bug-407a)))
+(defun bug-407b ()
+ (loop for n from (expt 2 1024) upto (+ 10 (expt 2 1024))
+ do (handler-case
+ (format t "~E~%" (coerce n 'single-float))
+ (simple-type-error ()
+ (return-from bug-407b :type-error)))))
+(assert (eq :type-error (bug-407b)))
+
+;; 1.0.29.44 introduces a ton of changes for complex floats
+;; on x86-64. Huge test of doom to help catch weird corner
+;; cases.
+;; Abuse the framework to also test some float arithmetic
+;; changes wrt constant arguments in 1.0.29.54.
+(defmacro def-compute (name real-type
+ &optional (complex-type `(complex ,real-type)))
+ `(defun ,name (x y r)
+ (declare (type ,complex-type x y)
+ (type ,real-type r))
+ (flet ((reflections (x)
+ (values x
+ (conjugate x)
+ (complex (- (realpart x)) (imagpart x))
+ (- x)))
+ (compute (x y r)
+ (declare (type ,complex-type x y)
+ (type ,real-type r))
+ (list (1+ x) (* 2 x) (/ x 2) (= 1 x)
+ (+ x y) (+ r x) (+ x r)
+ (- x y) (- r x) (- x r)
+ (* x y) (* x r) (* r x)
+ (unless (zerop y)
+ (/ x y))
+ (unless (zerop r)
+ (/ x r))
+ (unless (zerop x)
+ (/ r x))
+ (conjugate x) (conjugate r)
+ (abs r) (- r) (= 1 r)
+ (- x) (1+ r) (* 2 r) (/ r 2)
+ (complex r) (complex r r) (complex 0 r)
+ (= x y) (= r x) (= y r) (= x (complex 0 r))
+ (= r (realpart x)) (= (realpart x) r)
+ (> r (realpart x)) (< r (realpart x))
+ (> (realpart x) r) (< (realpart x) r)
+ (eql x y) (eql x (complex r)) (eql y (complex r))
+ (eql x (complex r r)) (eql y (complex 0 r))
+ (eql r (realpart x)) (eql (realpart x) r))))
+ (declare (inline reflections))
+ (multiple-value-bind (x1 x2 x3 x4) (reflections x)
+ (multiple-value-bind (y1 y2 y3 y4) (reflections y)
+ #.(let ((form '(list)))
+ (dolist (x '(x1 x2 x3 x4) (reverse form))
+ (dolist (y '(y1 y2 y3 y4))
+ (push `(list ,x ,y r
+ (append (compute ,x ,y r)
+ (compute ,x ,y (- r))))
+ form)))))))))
+
+(def-compute compute-number real number)
+(def-compute compute-single single-float)
+(def-compute compute-double double-float)