From 90aabcc56556c09a65e4257630b10589aab2d3dd Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 16 Jul 2015 09:58:59 +0200 Subject: [PATCH] Fix type/range inference for mul * module/language/cps2/types.scm (mul): Fix nan testing. --- module/language/cps2/types.scm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/module/language/cps2/types.scm b/module/language/cps2/types.scm index 6fca57d73..07da3d6a0 100644 --- a/module/language/cps2/types.scm +++ b/module/language/cps2/types.scm @@ -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))