Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Can you optimize my fibs?

Name: Anonymous 2015-12-16 17:07

Hi /frog/,

I've been tweaking my fibs implementation and it still seems slow in some cases.

How could I make it faster? Any ideas? Any obvious optimilizations I'm missing here?

fibs:
cmp rdi, 1
ja .l1
mov rax, rdi
ret
.l1:
dec rdi
push rdi
call fibs
pop rdi
push rax
dec rdi
call fibs
pop rcx
add rax, rcx
ret

Name: Cudder !cXCudderUE 2015-12-19 3:37

>>22
Like I said, it is several times slower on Intel CPUs. Try AMD instead. (Then everyone using an Intel one can go complain to them about how AMD is better, maybe they'll fix loop in the next model.)

n = 0 is not supposed to work. I define F(1) = 1. By introducing an extra instruction you've added over 16% more instructions to my solution.

You've also made everything a constant, meaning the compiler could optimise it into a single return (n) in the C case.

Now do a real efficiency comparison (size/time, smaller is better) and you'll find your bloated C compiler generated output is far behind...

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List