Archived

This topic is now archived and is closed to further replies.

Fast Zero Checking

This topic is 5378 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yes.

xor eax, eax
mov ecx, cnt
mov edi, buf
repz scasd
jnz not_all_0


A loop will likely be faster, though, on >= 586 CPUs.
Compare dwords, not floats (requires fcom, fnstsw, lahf => sloow), and unroll the loop. If the array is really big, think about checking qwords at a time; also, prefetch.

Share this post


Link to post
Share on other sites