Re: Ideas for reducing memory copying and zeroing times (fwd)

Robert L Krawitz (rlk@tiac.net)
Fri, 19 Apr 1996 10:04:55 -0400


Date: Fri, 19 Apr 1996 09:14:11 +0300 (EET DST)
From: Linus Torvalds <torvalds@cs.helsinki.fi>

No, the fastest, and shortest way to do it is

.. dest in %edi ..
movl $1024,%ecx
xorl %eax,%eax
rep; stosl

Which is in fact exactly how linux does it..

Not on the Pentium, it isn't. This is:

...save FPU state...expensive, but cheap compared to clearing 4K bytes...
1:
fstl (%edi)
addl $8, %edi
subl $8, %ecx
jne 1b
...restore FPU state...

(Hint: the above _really_ flies on a PPro. Intel optimized it to do
cache-line accesses, it seems. They did the right thing)

Pity they didn't make it do the right thing on the Pentium...

-- 
Robert Krawitz <rlk@tiac.net>           http://www.tiac.net/users/rlk/

Member of the League for Programming Freedom -- mail lpf@uunet.uu.net Tall Clubs International -- tci-request@aptinc.com or 1-800-521-2512