diff --git a/src/compiler/float-tran.lisp b/src/compiler/float-tran.lisp index f4744299f5f7a20684e5cda8953351e466633ee4..23aa93f572c6ed04f426cc5ece363b09fd39ebc5 100644 --- a/src/compiler/float-tran.lisp +++ b/src/compiler/float-tran.lisp @@ -2084,13 +2084,13 @@ (when x (nth-value 1 (decode-float x)))) (min-exp () - ;; Use decode-float on 0 of the appropriate type to find - ;; the min exponent. If we don't know the actual number - ;; format, use double, which has the widest range - ;; (including double-double-float). - (if (numeric-type-format arg) - (nth-value 1 (decode-float (coerce 0 (numeric-type-format arg)))) - (nth-value 1 (decode-float (coerce 0 'double-float))))) + ;; Use decode-float on the least positive float of the + ;; appropriate type to find the min exponent. If we don't + ;; know the actual number format, use double, which has the + ;; widest range (including double-double-float). + (nth-value 1 (decode-float (if (eq 'single-float (numeric-type-format arg)) + least-positive-single-float + least-positive-double-float)))) (max-exp () ;; Use decode-float on the most postive number of the ;; appropriate type to find the max exponent. If we don't diff --git a/tests/float-tran.lisp b/tests/float-tran.lisp index 0c47dce47047127aa72002f5f750de0ed4160eda..9b84659e06d91e004f0236206d9f4b8f121d6a44 100644 --- a/tests/float-tran.lisp +++ b/tests/float-tran.lisp @@ -17,6 +17,22 @@ (c::decode-float-sign-derive-type-aux (c::specifier-type '(single-float (0f0)))))) +(define-test decode-float-exp + "Test type derivation of the exponent from decode-float" + (assert-equalp (c::specifier-type '(integer -148 128)) + (c::decode-float-exp-derive-type-aux + (c::specifier-type 'single-float))) + (assert-equalp (c::specifier-type '(integer -1073 1024)) + (c::decode-float-exp-derive-type-aux + (c::specifier-type 'double-float))) + #+double-double + (assert-equalp (c::specifier-type '(integer -1073 1024)) + (c::decode-float-exp-derive-type-aux + (c::specifier-type 'double-double-float))) + (assert-equalp (c::specifier-type '(integer 2 8)) + (c::decode-float-exp-derive-type-aux + (c::specifier-type '(double-float 2d0 128d0))))) + (define-test log2-single-transform "Test tranform of (log x 2) to (kernel::log2 x)" (let ((test-fun