unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: bug-guile@gnu.org
Subject: Re: peval error
Date: Sat, 17 Sep 2011 10:54:33 -0700	[thread overview]
Message-ID: <8762kr9hra.fsf@pobox.com> (raw)
In-Reply-To: <87litni5lp.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sat, 17 Sep 2011 16:52:18 +0200")

On Sat 17 Sep 2011 07:52, ludo@gnu.org (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	other threads:[~2011-09-17 17:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-10 17:35 peval error Andy Wingo
2011-09-10 23:05 ` Ludovic Courtès
2011-09-13 17:04 ` Ludovic Courtès
2011-09-15 18:23   ` Andy Wingo
2011-09-15 21:44     ` Ludovic Courtès
2011-09-16 10:02       ` Ludovic Courtès
2011-09-17  0:43         ` Andy Wingo
2011-09-17 10:31           ` Ludovic Courtès
2011-09-17 14:52           ` Ludovic Courtès
2011-09-17 17:54             ` Andy Wingo [this message]
2011-09-18 10:00               ` bug#9542: " Ludovic Courtès
2011-09-18 21:05               ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8762kr9hra.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=bug-guile@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).