[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 23/30: Minor refactoring to type inference on < and =
From: |
Andy Wingo |
Subject: |
[Guile-commits] 23/30: Minor refactoring to type inference on < and = |
Date: |
Fri, 24 Nov 2017 09:24:24 -0500 (EST) |
wingo pushed a commit to branch master
in repository guile.
commit 31691000b7adeb2f28c16da0e7f8273ff009b321
Author: Andy Wingo <address@hidden>
Date: Wed Nov 22 11:09:18 2017 +0100
Minor refactoring to type inference on < and =
* module/language/cps/types.scm (infer-=): Factor out of
`define-=-inferrer'.
(define-<-inferrer): Remove unused definition.
(=, u64-=, s64-=): Use infer-=.
---
module/language/cps/types.scm | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index 20a648f..d3a6b20 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -1013,14 +1013,12 @@ minimum, and maximum."
;;; Numbers.
;;;
-(define-syntax-rule (define-=-inferrer (op &domain))
- (define-predicate-inferrer (op a b true?)
- (let ((types (logior (&type a) (&type b))))
- (when (and true? (type<=? types &domain))
- (let ((min (max (&min a) (&min b)))
- (max (min (&max a) (&max b))))
- (restrict! a &domain min max)
- (restrict! b &domain min max))))))
+(define-syntax-rule (infer-= a b true?)
+ (when true?
+ (let ((min (max (&min a) (&min b)))
+ (max (min (&max a) (&max b))))
+ (restrict! a &all-types min max)
+ (restrict! b &all-types min max))))
(define-syntax-rule (infer-integer-< a b true?)
(let ((min0 (&min a)) (max0 (&max a))
@@ -1034,7 +1032,13 @@ minimum, and maximum."
(restrict! b &all-types min1 (min max0 max1))))))
(define-simple-type-checker (= &number &number))
-(define-=-inferrer (= &number))
+(define-predicate-inferrer (= a b true?)
+ (let ((types (logior (&type a) (&type b))))
+ (when (type<=? types &number)
+ ;; OK if e.g. A is a NaN; in that case the range will be
+ ;; -inf/+inf.
+ (infer-= a b true?))))
+
(define-simple-type-checker (< &real &real))
(define-predicate-inferrer (< a b true?)
(let ((types (logior (&type a) (&type b))))
@@ -1064,11 +1068,13 @@ minimum, and maximum."
(restrict! a &exact-number (max min0 min1) max0)
(restrict! b &exact-number min1 (min max0 max1)))))))))
-(define-=-inferrer (u64-= &u64))
+(define-predicate-inferrer (u64-= a b true?)
+ (infer-= a b true?))
(define-predicate-inferrer (u64-< a b true?)
(infer-integer-< a b true?))
-(define-=-inferrer (s64-= &s64))
+(define-predicate-inferrer (s64-= a b true?)
+ (infer-= a b true?))
(define-predicate-inferrer (s64-< a b true?)
(infer-integer-< a b true?))
- [Guile-commits] 13/30: Minor compile-cps refactor, (continued)
- [Guile-commits] 13/30: Minor compile-cps refactor, Andy Wingo, 2017/11/24
- [Guile-commits] 15/30: DCE eliminates effect-free branches to the same continuation, Andy Wingo, 2017/11/24
- [Guile-commits] 29/30: DCE of branches punches through dead terms, Andy Wingo, 2017/11/24
- [Guile-commits] 21/30: Improve type and range inference on bignums, Andy Wingo, 2017/11/24
- [Guile-commits] 10/30: Fix unboxed immediate range comparison type inference, Andy Wingo, 2017/11/24
- [Guile-commits] 04/30: Specialize-numbers reifies instructions that type-check, Andy Wingo, 2017/11/24
- [Guile-commits] 26/30: Better unboxing for logand over s64 values, Andy Wingo, 2017/11/24
- [Guile-commits] 16/30: intmap-remove returns empty-intmap if appropriate, Andy Wingo, 2017/11/24
- [Guile-commits] 25/30: Better type folding for = on exact numbers, Andy Wingo, 2017/11/24
- [Guile-commits] 28/30: Refactor to finish the primcalls-take-parameters work, Andy Wingo, 2017/11/24
- [Guile-commits] 23/30: Minor refactoring to type inference on < and =,
Andy Wingo <=