[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 03/09: Fix intset-subtract to reliably produce empty-int
From: |
Andy Wingo |
Subject: |
[Guile-commits] 03/09: Fix intset-subtract to reliably produce empty-intset |
Date: |
Wed, 15 Jul 2015 07:51:34 +0000 |
wingo pushed a commit to branch master
in repository guile.
commit dc27708f0b0b039d9356e8d93d71daf563906fb7
Author: Andy Wingo <address@hidden>
Date: Mon Jul 13 11:03:00 2015 +0200
Fix intset-subtract to reliably produce empty-intset
* module/language/cps/intset.scm (intset-subtract): Reliably produce
empty-intset if the result is empty.
---
module/language/cps/intset.scm | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/module/language/cps/intset.scm b/module/language/cps/intset.scm
index 7f8316e..005bb7e 100644
--- a/module/language/cps/intset.scm
+++ b/module/language/cps/intset.scm
@@ -646,10 +646,10 @@
(else (make-intset/prune a-min a-shift root)))))))))
(define (intset-subtract a b)
- (define tmp (new-leaf))
;; Intersect leaves.
(define (subtract-leaves a b)
- (logand a (lognot b)))
+ (let ((out (logand a (lognot b))))
+ (if (zero? out) #f out)))
;; Subtract B from A starting at index I; the result will be fresh.
(define (subtract-branches/fresh shift a b i fresh)
(let lp ((i 0))
@@ -721,7 +721,9 @@
(new (lp a-min a-shift old)))
(if (eq? old new)
a-root
- (clone-branch-and-set a-root a-idx new)))))))))))
+ (let ((root (clone-branch-and-set a-root a-idx new)))
+ (and (or new (not (branch-empty? root)))
+ root))))))))))))
(define (bitvector->intset bv)
(define (finish-tail out min tail)
- [Guile-commits] branch master updated (dbe6247 -> 981802c), Andy Wingo, 2015/07/15
- [Guile-commits] 01/09: Reorganizing of intset/intmap helper functions, Andy Wingo, 2015/07/15
- [Guile-commits] 02/09: intset-union fast paths, Andy Wingo, 2015/07/15
- [Guile-commits] 03/09: Fix intset-subtract to reliably produce empty-intset,
Andy Wingo <=
- [Guile-commits] 04/09: CPS2 renumber works with first-order CPS, Andy Wingo, 2015/07/15
- [Guile-commits] 05/09: Tweak intset printing, Andy Wingo, 2015/07/15
- [Guile-commits] 06/09: Beginnings of first-order CPS optimization, Andy Wingo, 2015/07/15
- [Guile-commits] 07/09: Verify pass works on first-order CPS, Andy Wingo, 2015/07/15
- [Guile-commits] 09/09: Wire up new closure conversion pass, Andy Wingo, 2015/07/15
- [Guile-commits] 08/09: Add CPS2 closure conversion module, Andy Wingo, 2015/07/15