On Sat, May 18, 2019 at 06:15:07PM +0200, [email protected] 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

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to