X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Ffloat-tran.lisp;h=9e6033c1e9680b200480280b45707b8ecd7df917;hb=0302ff8f5d8557453b4b3c2032c224d95ddd4813;hp=538ccc05b41206453a30bd4c5398c65f9c902977;hpb=23b070aba7a0f3339358ef7dea05684f93b065a9;p=sbcl.git diff --git a/src/compiler/float-tran.lisp b/src/compiler/float-tran.lisp index 538ccc0..9e6033c 100644 --- a/src/compiler/float-tran.lisp +++ b/src/compiler/float-tran.lisp @@ -238,10 +238,18 @@ (ex-hi (numeric-type-high ex)) (new-lo nil) (new-hi nil)) - (when (and f-hi ex-hi) - (setf new-hi (scale-bound f-hi ex-hi))) - (when (and f-lo ex-lo) - (setf new-lo (scale-bound f-lo ex-lo))) + (when f-hi + (if (< (float-sign (type-bound-number f-hi)) 0.0) + (when ex-lo + (setf new-hi (scale-bound f-hi ex-lo))) + (when ex-hi + (setf new-hi (scale-bound f-hi ex-hi))))) + (when f-lo + (if (< (float-sign (type-bound-number f-lo)) 0.0) + (when ex-hi + (setf new-lo (scale-bound f-lo ex-hi))) + (when ex-lo + (setf new-lo (scale-bound f-lo ex-lo))))) (make-numeric-type :class (numeric-type-class f) :format (numeric-type-format f) :complexp :real @@ -624,9 +632,7 @@ (etypecase arg (numeric-type (cond ((eq (numeric-type-complexp arg) :complex) - (make-numeric-type :class (numeric-type-class arg) - :format (numeric-type-format arg) - :complexp :complex)) + (complex-float-type arg)) ((numeric-type-real-p arg) ;; The argument is real, so let's find the intersection ;; between the argument and the domain of the function. @@ -1297,19 +1303,34 @@ nil nil)) #'tan)) -;;; CONJUGATE always returns the same type as the input type. -;;; -;;; FIXME: ANSI allows any subtype of REAL for the components of COMPLEX. -;;; So what if the input type is (COMPLEX (SINGLE-FLOAT 0 1))? (defoptimizer (conjugate derive-type) ((num)) - (lvar-type num)) + (one-arg-derive-type num + (lambda (arg) + (flet ((most-negative-bound (l h) + (and l h + (if (< (type-bound-number l) (- (type-bound-number h))) + l + (set-bound (- (type-bound-number h)) (consp h))))) + (most-positive-bound (l h) + (and l h + (if (> (type-bound-number h) (- (type-bound-number l))) + h + (set-bound (- (type-bound-number l)) (consp l)))))) + (if (numeric-type-real-p arg) + (lvar-type num) + (let ((low (numeric-type-low arg)) + (high (numeric-type-high arg))) + (let ((new-low (most-negative-bound low high)) + (new-high (most-positive-bound low high))) + (modified-numeric-type arg :low new-low :high new-high)))))) + #'conjugate)) (defoptimizer (cis derive-type) ((num)) (one-arg-derive-type num - (lambda (arg) - (sb!c::specifier-type - `(complex ,(or (numeric-type-format arg) 'float)))) - #'cis)) + (lambda (arg) + (sb!c::specifier-type + `(complex ,(or (numeric-type-format arg) 'float)))) + #'cis)) ) ; PROGN