1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

Fix type/range inference for mul

* module/language/cps2/types.scm (mul): Fix nan testing.
This commit is contained in:
Andy Wingo 2015-07-16 09:58:59 +02:00
parent 420423f9a0
commit 90aabcc565

View file

@ -833,16 +833,17 @@ minimum, and maximum."
(define-simple-type-checker (mul &number &number))
(define-type-inferrer (mul a b result)
(let ((min-a (&min a)) (max-a (&max a))
(min-b (&min b)) (max-b (&max b)))
(min-b (&min b)) (max-b (&max b))
;; We only really get +inf.0 at runtime for flonums and
;; compnums. If we have inferred that the arguments are not
;; flonums and not compnums, then the result of (* +inf.0 0) at
;; range inference time is 0 and not +nan.0.
(nan-impossible? (not (logtest (logior (&type a) (&type b))
(logior &flonum &complex)))))
(define (nan* a b)
;; We only really get +inf.0 at runtime for flonums and compnums.
;; If we have inferred that the arguments are not flonums and not
;; compnums, then the result of (* +inf.0 0) at range inference
;; time is 0 and not +nan.0.
(if (and (or (and (inf? a) (zero? b))
(and (zero? a) (inf? b)))
(not (logtest (logior (&type a) (&type b))
(logior &flonum &complex))))
nan-impossible?)
0
(* a b)))
(let ((-- (nan* min-a min-b))