The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Stupid Pentium 4 by nix 2004-07-12 13:37:31
Apparently, the Pentium 4 has no SSE integer comparison operation. And emulating an integer comparison with floating-point compare operations is SLOW.

I have a 128-bit XMM register containing a bitfield. There are no restrictions on what bits are set (although it is highly probably that none are), and I need to find out if any of them are set. The best I have been able to come up with (that works in all cases) is
        movq    %xmm7, %xmm1            # set %xmm1 to 0
        cmpneqpd %xmm0, %xmm1           # compare u to 0, store result in %xmm1 
        movmskpd %xmm1, %edi            # move sign bits to %edi
        testl   %edi, %edi              # if u != 0f
        jne     .L67
        movq    %xmm7, %xmm1            # set %xmm1 to 0
        cmpunordpd %xmm0, %xmm1         # check if u is NaN
        movmskpd %xmm1, %edi            # move result to  %edi
        testl   %edi, %edi              # if u == NaN
        je     .L67
Anyone know of a faster way of checking this?

The next step in my algorithm, if the register is non-zero, is to extract one word at a time from %xmm0 and find out what bits are set using a bunch of shifts and ands. If the register is zero, this next part does nothing but waste time. As it is, my floating-point compare is so slow that the code runs faster if I just leave it out and let the processor waste time shifting zeroes around.
[ Reply ]
  Can you not just check if the Zero flag is set? by Tomo2004-07-12 14:12:49
    SSE operations don't set the status flags (n/t) by nix2004-07-12 14:14:24
      Thought that might be the case. by Tomo2004-07-12 14:22:25
      can you do a non-sse op on the register? by AndyA2004-07-12 15:10:42
        It's Intel. by LionsPhil2004-07-12 15:22:23

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)