bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: peval error


From: Andy Wingo
Subject: Re: peval error
Date: Sat, 17 Sep 2011 10:54:33 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

On Sat 17 Sep 2011 07:52, address@hidden (Ludovic Courtès) writes:

> Hopefully fixed!

Thanks!

Still, though, the results are not great:

  (define exp
    '(define (fact x)
       (letrec
           ((fold (lambda (f x b null? car cdr)
                    (if (null? x)
                        b
                        (f (car x) (fold f (cdr x) b null? car cdr))))))
         (fold * x 1 zero? (lambda (x) x) (lambda (x) (- x 1))))))

  (tree-il->scheme (optimize! (compile exp #:to 'tree-il) (current-module) '()))
  =>
  (define fact
    (lambda (#{x 265}#)
      (letrec*
        ((#{fold 268}#
           (lambda (#{f 269}#
                    #{x 270}#
                    #{b 271}#
                    #{null? 272}#
                    #{car 273}#
                    #{cdr 274}#)
             (if (#{null? 272}# #{x 270}#)
               #{b 271}#
               (#{f 269}# (#{car 273}# #{x 270}#)
                          (#{fold 268}#
                            #{f 269}#
                            (#{cdr 274}# #{x 270}#)
                            #{b 271}#
                            #{null? 272}#
                            #{car 273}#
                            #{cdr 274}#))))))
        (begin
          (if (zero? #{x 265}#)
            1
            (* (let ((#{x 281288}# #{x 265}#)) #{x 281288}#)
               (#{fold 268}#
                 *
                 (let ((#{x 283289}# #{x 265}#))
                   (#{1-}# #{x 283289}#))
                 1
                 zero?
                 (lambda (#{x 281290}#) #{x 281290}#)
                 (lambda (#{x 283291}#) (#{1-}# #{x 283291}#)))))))))

Here we see that `fold' was inlined once, but to no use.  More code for
no more speed.

Waddell and Dybvig report on similar problems in their inlining paper
(Fast and Effective Procedure Inlining, IU CS Dept. TR 484).  See
section 4.4 where they discuss this and similar problems.  We should
figure out what we can do in these cases; and in the case where we can't
fully inline a call site, perhaps we should abort the attempt to inline
it.

Andy
-- 
http://wingolog.org/



reply via email to

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