@cblake thanks for the explanation. I will check with the profiler. From what 
you said I tried this and get almost the same results - now for gcc and g++ and 
for clang a speed up of about 4x.
    
    
    proc fib(n: int): uint64 =
      if n > 1 and n != 30: return fib(n - 1) + fib(n - 2)
      if n <= 1: return 1
      let x {.global.}: auto = fib(29) + fib(28)
      return x
    
    
    echo fib(46)
    
    
    
    Run

as a side note: reordering the ifs brought about 50% speedup

Reply via email to