guile-commits
[Top][All Lists]
Advanced

[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 ()))



reply via email to

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