chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] [PATCH] Mostly fix #1604


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Mostly fix #1604
Date: Sat, 18 May 2019 23:09:25 +0200
User-agent: NeoMutt/20170113 (1.7.2)

On Sat, May 18, 2019 at 06:15:07PM +0200, address@hidden wrote:
> > Finally, I ran into this head scratcher: I tried to replace = with eq? in
> > the code and it sped up the code by a *lot*.  However, in fixnum
> > arithmetic mode, = gets rewritten to C_eqp.  The difference in the C
> > output is that the code that uses eq? directly gets this completely
> > inlined in the same C function as the following subtractions.  The code
> > that uses = will get the comparisons in a C function and then call a CPS
> > function which does the subtractions.  Any ideas why this is?  It makes
> > a massive difference, so I think it's worthwhile to at least understand
> > what's going on here.
> 
> Can you give an example? What does "in the code" mean? What code?

I changed:

(define (fib n)
  (if (or (= n 0) (= n 1))
      n
      (+ (fib (- n 1)) (fib (- n 2)))))

to:

(define (fib n)
  (if (or (eq? n 0) (eq? n 1))
      n
      (+ (fib (- n 1)) (fib (- n 2)))))


Cheers,
Peter

Attachment: signature.asc
Description: PGP signature


reply via email to

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