[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 22/41: Specialize u64 comparisons
From: |
Andy Wingo |
Subject: |
[Guile-commits] 22/41: Specialize u64 comparisons |
Date: |
Wed, 02 Dec 2015 08:06:53 +0000 |
wingo pushed a commit to branch master
in repository guile.
commit 163fcf5adb5700c8d5fe2e9bd0a57ce7c7bf1c34
Author: Andy Wingo <address@hidden>
Date: Fri Nov 20 09:26:56 2015 +0100
Specialize u64 comparisons
* module/language/cps/specialize-numbers.scm
(specialize-u64-comparison): New function.
* module/language/cps/specialize-numbers.scm (specialize-operations):
Rename from specialize-f64-operations, as it will specialize both
kinds. Add a case to specialize u64 comparisons.
* module/language/cps/specialize-numbers.scm (specialize-numbers): Adapt
to specialize-operations name change.
---
module/language/cps/specialize-numbers.scm | 35 ++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/module/language/cps/specialize-numbers.scm
b/module/language/cps/specialize-numbers.scm
index 5f15806..1050865 100644
--- a/module/language/cps/specialize-numbers.scm
+++ b/module/language/cps/specialize-numbers.scm
@@ -81,7 +81,22 @@
($continue kunbox-b src
($primcall 'scm->f64 (a)))))))
-(define (specialize-f64-operations cps)
+(define (specialize-u64-comparison cps kf kt src op a b)
+ (pk 'specialize cps kf kt src op a b)
+ (let ((op (symbol-append 'u64- op)))
+ (with-cps cps
+ (letv u64-a u64-b)
+ (letk kop ($kargs ('u64-b) (u64-b)
+ ($continue kf src
+ ($branch kt ($primcall op (u64-a u64-b))))))
+ (letk kunbox-b ($kargs ('u64-a) (u64-a)
+ ($continue kop src
+ ($primcall 'scm->u64 (b)))))
+ (build-term
+ ($continue kunbox-b src
+ ($primcall 'scm->u64 (a)))))))
+
+(define (specialize-operations cps)
(define (visit-cont label cont cps types)
(match cont
(($ $kfun)
@@ -101,6 +116,22 @@
(setk label ($kargs names vars ,body)))
cps)
types))))))
+ (($ $kargs names vars
+ ($ $continue k src
+ ($ $branch kt ($ $primcall (and op (or '< '<= '= '>= '>)) (a
b)))))
+ (call-with-values (lambda () (lookup-pre-type types label a))
+ (lambda (a-type a-min a-max)
+ (call-with-values (lambda () (lookup-pre-type types label b))
+ (lambda (b-type b-min b-max)
+ (values
+ (if (and (eqv? a-type b-type &exact-integer)
+ (<= 0 a-min a-max #xffffffffffffffff)
+ (<= 0 b-min b-max #xffffffffffffffff))
+ (with-cps cps
+ (let$ body (specialize-u64-comparison k kt src op a b))
+ (setk label ($kargs names vars ,body)))
+ cps)
+ types))))))
(_ (values cps types))))
(values (intmap-fold visit-cont cps cps #f)))
@@ -342,4 +373,4 @@
;; Type inference wants a renumbered graph; OK.
(let ((cps (renumber cps)))
(with-fresh-name-state cps
- (specialize-f64-phis (specialize-f64-operations cps)))))
+ (specialize-f64-phis (specialize-operations cps)))))
- [Guile-commits] 09/41: frame-call-representation avoids frame-procedure., (continued)
- [Guile-commits] 09/41: frame-call-representation avoids frame-procedure., Andy Wingo, 2015/12/02
- [Guile-commits] 15/41: Remove frame-procedure, Andy Wingo, 2015/12/02
- [Guile-commits] 13/41: Remove `procedure' repl command, Andy Wingo, 2015/12/02
- [Guile-commits] 14/41: VM traps don't match on value of slot 0, Andy Wingo, 2015/12/02
- [Guile-commits] 17/41: Remove frame->module, Andy Wingo, 2015/12/02
- [Guile-commits] 19/41: Add bv-length instruction, Andy Wingo, 2015/12/02
- [Guile-commits] 18/41: Range inference over the full U64+S64 range, Andy Wingo, 2015/12/02
- [Guile-commits] 20/41: bv-f{32, 64}-{ref, set!} take unboxed u64 index, Andy Wingo, 2015/12/02
- [Guile-commits] 23/41: Beginning of u64 phi unboxing, Andy Wingo, 2015/12/02
- [Guile-commits] 16/41: Add low-level support for unboxed 64-bit unsigned ints, Andy Wingo, 2015/12/02
- [Guile-commits] 22/41: Specialize u64 comparisons,
Andy Wingo <=
- [Guile-commits] 26/41: Slower range saturation in type inference, Andy Wingo, 2015/12/02
- [Guile-commits] 21/41: Add instructions to branch on u64 comparisons, Andy Wingo, 2015/12/02
- [Guile-commits] 25/41: Add unsigned 64-bit arithmetic operators: uadd, usub, umul, Andy Wingo, 2015/12/02
- [Guile-commits] 24/41: Unbox u64 phi values, Andy Wingo, 2015/12/02
- [Guile-commits] 28/41: Specialize u64 arithmetic, Andy Wingo, 2015/12/02
- [Guile-commits] 37/41: Disable warnings on bootstrap build, Andy Wingo, 2015/12/02
- [Guile-commits] 35/41: Add current-thread VM op, Andy Wingo, 2015/12/02
- [Guile-commits] 27/41: Better range inference for indexes of vector-ref, string-ref et al, Andy Wingo, 2015/12/02
- [Guile-commits] 29/41: Remove add1 and sub1, Andy Wingo, 2015/12/02
- [Guile-commits] 30/41: Add tagged and untagged arithmetic ops with immediate operands, Andy Wingo, 2015/12/02