[gambit-list] Guile's new compiler
Bradley Lucier
lucier at math.purdue.edu
Thu Nov 5 00:38:23 EST 2015
> On Nov 4, 2015, at 10:26 PM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
>
> As far as I can tell, all of those optimizations are currently done by the Gambit compiler except for loop-invariant code motion and loop inversion. I’m not sure how much those optimizations are useful however.
>
> Marc
OK.
What about this example:
[Media-Mac-mini-3:~] lucier% cat crap.scm
(define (a x y)
(map + x y))
[Media-Mac-mini-3:~] lucier% gsc -c -expansion crap
Expansion:
(define a
(lambda (x y)
(let ((temp.0 +))
(if (and ('#<procedure #2 ##eq?> map '#<procedure #3 map>) ('#<procedure #4 ##procedure?> temp.0))
(letrec ((loop1.3 (lambda (x y temp.0 temp.4 temp.5)
(if (and ('#<procedure #5 ##pair?> temp.4) ('#<procedure #5 ##pair?> temp.5))
(loop1.3 x y temp.0 ('#<procedure #6 ##cdr> temp.4) ('#<procedure #6 ##cdr> temp.5))
(if (and ('#<procedure #7 ##null?> temp.4) ('#<procedure #7 ##null?> temp.5))
(letrec ((loop2.6 (lambda (temp.0 temp.7 temp.8)
(if (and ('#<procedure #5 ##pair?> temp.7) ('#<procedure #5 ##pair?> temp.8))
(let ((x.9 (temp.0 ('#<procedure #8 ##car> temp.7) ('#<procedure #8 ##car> temp.8))))
('#<procedure #9 ##cons>
x.9
(loop2.6 temp.0 ('#<procedure #6 ##cdr> temp.7) ('#<procedure #6 ##cdr> temp.8))))
'()))))
(loop2.6 temp.0 x y))
(map temp.0 x y))))))
(loop1.3 x y temp.0 x y))
(map temp.0 x y)))))
The gambit compiler doesn’t specialize +.
Or even
[Media-Mac-mini-3:~] lucier% cat crap.scm
(define (a x y)
(map f64+ x y))
[Media-Mac-mini-3:~] lucier% gsc -c -expansion crap
Expansion:
(define a
(lambda (x y)
(let ((temp.0 f64+))
(if (and ('#<procedure #2 ##eq?> map '#<procedure #3 map>) ('#<procedure #4 ##procedure?> temp.0))
(letrec ((loop1.3 (lambda (x y temp.0 temp.4 temp.5)
(if (and ('#<procedure #5 ##pair?> temp.4) ('#<procedure #5 ##pair?> temp.5))
(loop1.3 x y temp.0 ('#<procedure #6 ##cdr> temp.4) ('#<procedure #6 ##cdr> temp.5))
(if (and ('#<procedure #7 ##null?> temp.4) ('#<procedure #7 ##null?> temp.5))
(letrec ((loop2.6 (lambda (temp.0 temp.7 temp.8)
(if (and ('#<procedure #5 ##pair?> temp.7) ('#<procedure #5 ##pair?> temp.8))
(let ((x.9 (temp.0 ('#<procedure #8 ##car> temp.7) ('#<procedure #8 ##car> temp.8))))
('#<procedure #9 ##cons>
x.9
(loop2.6 temp.0 ('#<procedure #6 ##cdr> temp.7) ('#<procedure #6 ##cdr> temp.8))))
'()))))
(loop2.6 temp.0 x y))
(map temp.0 x y))))))
(loop1.3 x y temp.0 x y))
(map temp.0 x y)))))
More information about the Gambit-list
mailing list