disclaimer: this is just for fun.... differences should be in the
noise in any complex system, and I'm not suggesting any code changes.

Actually, with 32 bit registers, x<0 should be faster than x==-1 by
one cycle.  If it doesn't test faster, then it's because of some
optimizations that could be pulled off via inlining and data flow
analysis (set of -1 followed by a check for -1, etc).

Here's the optimized code that gcc produces for a 64 bit long comparison:

        #  if (foo() == -1)
        andl    %edx, %eax
        incl    %eax
        jne     L2

        #  if (foo() < 0)
        testl   %edx, %edx
        jns     L9

-Yonik

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to