[gambit-list] More inlining notes

Bradley Lucier lucier at math.purdue.edu
Fri Mar 24 13:04:14 EST 2006


Marc:

It would help a lot of the inliner knew more about the ##fixnum.blah?  
operators, e.g., that

(##fixnum.+? x 0) == (##fixnum.+? 0 x) == x
(##fixnum.-? x 0) == x
(##fixnum.*? x 1) == (##fixnum.*? 1 x) == x
(##fixnum.*? x 0) == (##fixnum.*? 0 x) == 0
(##fixnum.quotient x 1) == x
(##fixnum.remainder x 1) == 0
(##fixnum.modulo    x 1) == 0

I'm including example code and the expansion at the end of this e-mail.

I'm thinking more and more that OPTIMIZE_SPACE should be defined by  
default in the .c file if any of the mostly-* declarations are in  
effect; there are just too many damn function calls generated with  
these options.  Or maybe that it should just be defined by default  
unless a -optimize-space option is passed to gsc.

Brad

[lindv2:Arrays/srfi3/gsc-test] lucier% cat test.scm
(define (a x)
   (- x 0))

(define (b x)
   (+ x 0))

(define (c x)
   (+ 0 x))

(define (d x)
   (* 1 x))

(define (e x)
   (* 0 x))

(define (f x)
   (quotient x 1))

(define (g x)
   (remainder x 1))
[lindv2:Arrays/srfi3/gsc-test] lucier% gsc -c -expansion test.scm
Expansion:

(define a:2
   (lambda (x:3)
     (if (and (##eq?:4 -:5 '#<procedure #9 ->) (##fixnum?:6 x:3))
         (let ((temp.2:7 (##fixnum.-?:8 x:3 0))) (if temp.2:7 temp. 
2:7 (-:5 x:3 0)))
         (-:5 x:3 0))))

(define b:10
   (lambda (x:11)
     (if (and (##eq?:4 +:12 '#<procedure #15 +>) (##fixnum?:6 x:11))
         (let ((temp.5:13 (##fixnum.+?:14 x:11 0))) (if temp.5:13  
temp.5:13 (+:12 x:11 0)))
         (+:12 x:11 0))))

(define c:16
   (lambda (x:17)
     (if (and (##eq?:4 +:12 '#<procedure #15 +>) (and (##fixnum?:6 x: 
17) #t))
         (let ((temp.8:18 (##fixnum.+?:14 0 x:17))) (if temp.8:18  
temp.8:18 (+:12 0 x:17)))
         (+:12 0 x:17))))

(define d:19
   (lambda (x:20)
     (if (and (##eq?:4 *:21 '#<procedure #25 *>) (and (##fixnum?:6 x: 
20) #t))
         (if (##eqv?:22 x:20 0)
             0
             (let ((temp.11:23 (if (##eqv?:22 x:20 -1) -1  
(##fixnum.*?:24 1 x:20))))
               (if temp.11:23 temp.11:23 (*:21 1 x:20))))
         (*:21 1 x:20))))

(define e:26
   (lambda (x:27)
     (if (and (##eq?:4 *:21 '#<procedure #25 *>) (and (##fixnum?:6 x: 
27) #t))
         (if (##eqv?:22 x:27 0)
             0
             (let ((temp.14:28 (if (##eqv?:22 x:27 -1) 0 (##fixnum.*?: 
24 0 x:27))))
               (if temp.14:28 temp.14:28 (*:21 0 x:27))))
         (*:21 0 x:27))))

(define f:29
   (lambda (x:30)
     (if (and (##eq?:4 quotient:31 '#<procedure #33 quotient>) (and  
(##fixnum?:6 x:30) #t))
         (##fixnum.quotient:32 x:30 1)
         (quotient:31 x:30 1))))

(define g:34
   (lambda (x:35)
     (if (and (##eq?:4 remainder:36 '#<procedure #38 remainder>) (and  
(##fixnum?:6 x:35) #t))
         (##fixnum.remainder:37 x:35 1)
         (remainder:36 x:35 1))))




More information about the Gambit-list mailing list