[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 12/16: Specialize primcalls more aggressively
From: |
Andy Wingo |
Subject: |
[Guile-commits] 12/16: Specialize primcalls more aggressively |
Date: |
Sun, 5 Nov 2017 09:00:42 -0500 (EST) |
wingo pushed a commit to branch master
in repository guile.
commit 5457f28af9c4cea934f61b0e11e2ebdd7e2ce718
Author: Andy Wingo <address@hidden>
Date: Fri Nov 3 09:28:27 2017 +0100
Specialize primcalls more aggressively
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
Don't restrict /imm params to encodeable immediates; specialize any
imm. Rely on reify-primitives to undo the transformation if needed.
---
module/language/cps/specialize-primcalls.scm | 41 ++++++++++++++--------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/module/language/cps/specialize-primcalls.scm
b/module/language/cps/specialize-primcalls.scm
index 1bde78a..6e92365 100644
--- a/module/language/cps/specialize-primcalls.scm
+++ b/module/language/cps/specialize-primcalls.scm
@@ -33,15 +33,14 @@
(define (specialize-primcalls conts)
(let ((constants (compute-constant-values conts)))
- (define (u6? var)
+ (define (uint? var)
(let ((val (intmap-ref constants var (lambda (_) #f))))
- (and (exact-integer? val) (<= 0 val 63))))
- (define (u8? var)
- (let ((val (intmap-ref constants var (lambda (_) #f))))
- (and (exact-integer? val) (<= 0 val 255))))
+ (and (exact-integer? val) (<= 0 val))))
(define (u64? var)
(let ((val (intmap-ref constants var (lambda (_) #f))))
(and (exact-integer? val) (<= 0 val #xffffFFFFffffFFFF))))
+ (define (num? var)
+ (number? (intmap-ref constants var (lambda (_) #f))))
(define (s64? var)
(let ((val (intmap-ref constants var (lambda (_) #f))))
(and (exact-integer? val)
@@ -60,22 +59,22 @@
...
(_ #f)))
(specialize-case
- (('make-vector (? u8? n) init) (make-vector/immediate n (init)))
- (('vector-ref v (? u8? n)) (vector-ref/immediate n (v)))
- (('vector-set! v (? u8? n) x) (vector-set!/immediate n (v x)))
- (('allocate-struct v (? u8? n)) (allocate-struct/immediate n (v)))
- (('struct-ref s (? u8? n)) (struct-ref/immediate n (s)))
- (('struct-set! s (? u8? n) x) (struct-set!/immediate n (s x)))
- (('add x (? u8? y)) (add/immediate y (x)))
- (('add (? u8? y) x) (add/immediate y (x)))
- (('sub x (? u8? y)) (sub/immediate y (x)))
- (('uadd x (? u8? y)) (uadd/immediate y (x)))
- (('uadd (? u8? y) x) (uadd/immediate y (x)))
- (('usub x (? u8? y)) (usub/immediate y (x)))
- (('umul x (? u8? y)) (umul/immediate y (x)))
- (('umul (? u8? y) x) (umul/immediate y (x)))
- (('ursh x (? u6? y)) (ursh/immediate y (x)))
- (('ulsh x (? u6? y)) (ulsh/immediate y (x)))
+ (('make-vector (? uint? n) init) (make-vector/immediate n (init)))
+ (('vector-ref v (? uint? n)) (vector-ref/immediate n (v)))
+ (('vector-set! v (? uint? n) x) (vector-set!/immediate n (v x)))
+ (('allocate-struct v (? uint? n)) (allocate-struct/immediate n (v)))
+ (('struct-ref s (? uint? n)) (struct-ref/immediate n (s)))
+ (('struct-set! s (? uint? n) x) (struct-set!/immediate n (s x)))
+ (('add x (? num? y)) (add/immediate y (x)))
+ (('add (? num? y) x) (add/immediate y (x)))
+ (('sub x (? num? y)) (sub/immediate y (x)))
+ (('uadd x (? uint? y)) (uadd/immediate y (x)))
+ (('uadd (? uint? y) x) (uadd/immediate y (x)))
+ (('usub x (? uint? y)) (usub/immediate y (x)))
+ (('umul x (? uint? y)) (umul/immediate y (x)))
+ (('umul (? uint? y) x) (umul/immediate y (x)))
+ (('ursh x (? uint? y)) (ursh/immediate y (x)))
+ (('ulsh x (? uint? y)) (ulsh/immediate y (x)))
(('scm->f64 (? f64? var)) (load-f64 var ()))
(('scm->u64 (? u64? var)) (load-u64 var ()))
(('scm->u64/truncate (? u64? var)) (load-u64 var ()))
- [Guile-commits] branch master updated (2d8c75f -> f96a670), Andy Wingo, 2017/11/05
- [Guile-commits] 10/16: Tweak optimization order, Andy Wingo, 2017/11/05
- [Guile-commits] 12/16: Specialize primcalls more aggressively,
Andy Wingo <=
- [Guile-commits] 13/16: Earlier conversion to /imm primcalls, Andy Wingo, 2017/11/05
- [Guile-commits] 02/16: cache-current-module, etc use immediate primcall parameters, Andy Wingo, 2017/11/05
- [Guile-commits] 05/16: Immediate variants of vector-ref, etc use immediate param, Andy Wingo, 2017/11/05
- [Guile-commits] 15/16: error, scm-error primcalls expand to `throw', Andy Wingo, 2017/11/05
- [Guile-commits] 07/16: builtin-ref takes immediate parameter, Andy Wingo, 2017/11/05
- [Guile-commits] 09/16: reify-primitives reifies constants for out-of-range imm params, Andy Wingo, 2017/11/05
- [Guile-commits] 03/16: load-f64, etc take immediate parameters, Andy Wingo, 2017/11/05
- [Guile-commits] 04/16: free-ref, free-set take immediate parameters, Andy Wingo, 2017/11/05
- [Guile-commits] 11/16: (system base types) uses target's idea of max size_t, Andy Wingo, 2017/11/05
- [Guile-commits] 16/16: Add new "throw" VM ops, Andy Wingo, 2017/11/05