summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2017-03-09 15:13:19 +0100
committerDaniel Llorens <daniel.llorens@bluewin.ch>2017-03-09 15:17:35 +0100
commit7de77bf7d8016446b4fcddb36e588406266ec40a (patch)
treec8e3cac8b096be23938a5b8dde366197eb848c09
parent7cdfaaada9a9c5a491c393be4cfd475fe61637b8 (diff)
downloadguile-7de77bf7d8016446b4fcddb36e588406266ec40a.tar.gz
Fix bug in comparison between real and complex
This bug was introduced by 35a90592501ebde7e7ddbf2486ca9d315e317d09. * module/language/cps/specialize-numbers.scm (specialize-operations): Check that both operands are real as a condition for specialize-f64-comparison. * test-suite/tests/numbers.test: Add test.
-rw-r--r--module/language/cps/specialize-numbers.scm14
-rw-r--r--test-suite/tests/numbers.test9
2 files changed, 17 insertions, 6 deletions
diff --git a/module/language/cps/specialize-numbers.scm b/module/language/cps/specialize-numbers.scm
index 808ea6705..d5587037b 100644
--- a/module/language/cps/specialize-numbers.scm
+++ b/module/language/cps/specialize-numbers.scm
@@ -51,6 +51,7 @@
(define-module (language cps specialize-numbers)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-11)
#:use-module (language cps)
#:use-module (language cps intmap)
#:use-module (language cps intset)
@@ -301,11 +302,12 @@ BITS indicating the significant bits needed for a variable. BITS may be
(lambda (type min max)
(and (eqv? type &exact-integer)
(<= 0 min max #xffffffffffffffff))))))
- (define (f64-operand? var)
- (call-with-values (lambda ()
- (lookup-pre-type types label var))
- (lambda (type min max)
- (and (eqv? type &flonum)))))
+ (define (f64-operands? vara varb)
+ (let-values (((typea mina maxa) (lookup-pre-type types label vara))
+ ((typeb minb maxb) (lookup-pre-type types label varb)))
+ (and (zero? (logand (logior typea typeb) (lognot &real)))
+ (or (eqv? typea &flonum)
+ (eqv? typeb &flonum)))))
(match cont
(($ $kfun)
(let ((types (infer-types cps label)))
@@ -411,7 +413,7 @@ BITS indicating the significant bits needed for a variable. BITS may be
($ $branch kt ($ $primcall (and op (or '< '<= '= '>= '>)) (a b)))))
(values
(cond
- ((or (f64-operand? a) (f64-operand? b))
+ ((f64-operands? a b)
(with-cps cps
(let$ body (specialize-f64-comparison k kt src op a b))
(setk label ($kargs names vars ,body))))
diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test
index 0adf21637..a0403a118 100644
--- a/test-suite/tests/numbers.test
+++ b/test-suite/tests/numbers.test
@@ -5425,3 +5425,12 @@
(test-ash-variant 'ash ash floor)
(test-ash-variant 'round-ash round-ash round))
+
+;;;
+;;; regressions
+;;;
+
+(with-test-prefix/c&e "bug in unboxing f64 in 2.1.6"
+
+ (pass-if "= real and complex"
+ (= 1.0 (make-rectangular 1.0 0.0))))