Commit e99b2b29 authored by Raymond Toy's avatar Raymond Toy
Browse files

Document why %unary-ftruncate multiplies the result by x when result =

0.
parent d337d008
...@@ -210,10 +210,9 @@ ...@@ -210,10 +210,9 @@
;; if x is known to be of the right type. Also, if the result is ;; if x is known to be of the right type. Also, if the result is
;; known to fit in the same range as a (signed-byte 32), convert this ;; known to fit in the same range as a (signed-byte 32), convert this
;; to %unary-truncate, which might be a single instruction, and float ;; to %unary-truncate, which might be a single instruction, and float
;; the result. However, for sparc, we have a vop to do this so call ;; the result. However, for sparc and x86, we have a vop to do this
;; that, and for Sparc V9, we can actually handle a 64-bit integer ;; so call that, and for Sparc V9, we can actually handle a 64-bit
;; range. ;; integer range.
(macrolet ((frob (ftype func) (macrolet ((frob (ftype func)
`(deftransform %unary-ftruncate ((x) (,ftype)) `(deftransform %unary-ftruncate ((x) (,ftype))
(let* ((x-type (continuation-type x)) (let* ((x-type (continuation-type x))
...@@ -226,6 +225,9 @@ ...@@ -226,6 +225,9 @@
(< hi limit-hi)) (< hi limit-hi))
#-(or sparc (and x86 sse2)) #-(or sparc (and x86 sse2))
'(let ((result (coerce (%unary-truncate x) ',ftype))) '(let ((result (coerce (%unary-truncate x) ',ftype)))
;; Multiply by x when result is 0 so that we
;; get the correct signed zero to match what
;; ftruncate in float.lisp would return.
(if (zerop result) (if (zerop result)
(* result x) (* result x)
result)) result))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment