guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 04/04: Tighten up range inference for scm->u64/truncate


From: Andy Wingo
Subject: [Guile-commits] 04/04: Tighten up range inference for scm->u64/truncate
Date: Wed, 25 Sep 2024 11:46:03 -0400 (EDT)

wingo pushed a commit to branch main
in repository guile.

commit 30c3849092b17a56b9b74dd23da121afc5076e08
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Wed Sep 25 17:27:17 2024 +0200

    Tighten up range inference for scm->u64/truncate
    
    * module/language/cps/types.scm (scm->u64/truncate): Better range
    analysis.
---
 module/language/cps/types.scm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index 512be4bb2..db4a8c7c8 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -1008,10 +1008,12 @@ minimum, and maximum."
   (define! result &u64 param param))
 
 (define-type-checker (scm->u64/truncate scm)
-  (check-type scm &exact-integer &range-min &range-max))
+  (check-type scm &exact-integer -inf.0 +inf.0))
 (define-type-inferrer (scm->u64/truncate scm result)
-  (restrict! scm &exact-integer &range-min &range-max)
-  (define! result &u64 0 &u64-max))
+  (restrict! scm &exact-integer -inf.0 +inf.0)
+  (if (<= 0 (&min scm) (&max scm) &u64-max)
+      (define! result &u64 (&min scm) (&max scm))
+      (define! result &u64 0 &u64-max)))
 
 (define-type-checker (u64->scm u64)
   #t)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]